Querying in the Data Intelligence Platform

Introduction to Databricks SQL

Kevin Barlow

Data Manager

Motivation

Lakehouse Diagram - Transformation

Introduction to Databricks SQL

Motivation

Lakehouse Diagram - Analysis

Introduction to Databricks SQL

SQL query basics

  • Based on ANSI SQL
  • Common patterns and functions to other SQL syntaxes
    • SELECT ... FROM ... syntaxes
    • Built-in and custom functions
    • Query data tables in Unity Catalog or in other database systems
SELECT
    id,
    name,
    product,
    store_id,
    sales,
    unit_price,
FROM
    sales_data
WHERE
    sales > 10 AND
    product IN ('widget', 'thingy')
Introduction to Databricks SQL

Common functions

  • Databricks SQL functions mirror some of the most common operations in SQL, Python, and Spark
    • ROUND() and FORMAT_NUMBER()
    • CONCAT(), LEFT(), and RIGHT()
    • DATE(), DATE_ADD(), and DATE_DIFF()
    • CASE, IF(), and ISNULL()
    • FROM_CSV() and FROM_JSON()
  • Create a custom User Defined Function (UDF)
SELECT
    id,
    initcap(name) as name,
    right(product, 10) as productSKU,
    store_id,
    int(sales) as numSales,
    round(unit_price, 2) as unit_price
FROM
    sales_data
WHERE
    sales > 10 AND
    product IN ('widget', 'thingy')
Introduction to Databricks SQL

Visualizations

  • Visual representations of our query results
  • Support for the most common visual types
    • Bar and line charts
    • Donut charts
    • Map visualizations
    • Pivot tables

Stacked bar chart

Line chart

Introduction to Databricks SQL

Let's practice!

Introduction to Databricks SQL

Preparing Video For Download...