Product area

SQL the Databricks Way

The SQL fundamentals that actually matter on Databricks: Spark SQL, differences from Postgres, types, functions, and the patterns that keep showing up in exams.

Concepts

9 in this area
  1. 1Spark SQL, the dialectSpark SQL is the dialect you write everywhere on Databricks: in the SQL editor, inside a notebook cell, behind spark.sql(...) in PySpark, and inside a pipeline. It looks close enough to Postgres or MySQL that a query someone learned on psql will often just…
  2. 2Types and castingSpark SQL's type system covers the usual numeric, string, and temporal types, plus complex types (ARRAY, MAP, STRUCT) and VARIANT for semi-structured values (see semi structured data). Types matter more here than in a row-store: Delta stores data…
  3. 3Joins and set operationsJoins combine rows from two table references on a matching condition; set operators combine the results of two queries with the same shape. Spark SQL's SQL-level syntax reads like any relational database, but the plan it compiles to is distributed - matching…
  4. 4Window functionsA window function computes a value per row using a set of "peer" rows - defined by PARTITION BY and ORDER BY - without collapsing them into one row the way GROUP BY does. Ranking a row within its group, comparing it to the previous row, or running a…
  5. 5MERGE, UPDATE, DELETE on DeltaMERGE INTO, UPDATE, DELETE, and INSERT OVERWRITE are the statements that change data already sitting in a Delta table instead of just appending to it. They read like ordinary DML from any relational database, but Delta has no in-place row storage: every one…
  6. 6Metric viewsA metric view is a Unity Catalog securable whose definition is a YAML document rather than a SELECT. The YAML names a source, optional joins and a filter, then two lists: fields (scalar expressions you group and filter by) and measures (aggregate expressions…
  7. 7AI functions in SQLAI functions are built-in SQL functions, all named ai, that apply a model to a column. They run from the SQL editor, from notebooks, from Lakeflow pipelines and from jobs, and they need no endpoint of your own: the query runs on the compute you submit it…
  8. 8Pipe syntax for queriesAny query on Databricks can be followed by a chain of pipe operators, each separated by the token |> and each consuming the result of the one before it. A pipeline normally starts with FROM main.silver.orders or TABLE main.silver.orders, but any query can…
  9. 9SQL scripting and stored proceduresSQL scripting is the procedural half of Databricks SQL. Everything lives inside a compound statement: a BEGIN ... END block that first declares local variables, conditions, cursors and error handlers, then runs a sequence of queries, DML, DDL, GRANT, loops…

News

No news for this area.

Resources

Use ai_queryDocumentation · DatabricksFreeTransform unstructured data using AI FunctionsDocumentation · DatabricksFreeai_extract functionDocumentation · DatabricksFreeai_classify functionDocumentation · DatabricksFreeai_translate functionDocumentation · DatabricksFreeai_forecast functionDocumentation · DatabricksFreeai_enrich functionDocumentation · DatabricksFreeVARIANT typeDocumentation · DatabricksFreeUnity Catalog semanticsDocumentation · DatabricksFreeUnity Catalog metric viewsDocumentation · DatabricksFreeCreate a metric viewDocumentation · DatabricksFreeMetric view YAML syntax referenceDocumentation · DatabricksFreeQuery metric viewsDocumentation · DatabricksFreeMetric view feature availabilityDocumentation · DatabricksFreeManage metric viewsDocumentation · DatabricksFreePiped operationDocumentation · DatabricksFreeSQL Pipeline SyntaxDocumentation · DatabricksFreeSQL scriptingDocumentation · DatabricksFreeBEGIN END compound statementDocumentation · DatabricksFreeCREATE PROCEDUREDocumentation · DatabricksFreeCALLDocumentation · DatabricksFreeEXECUTE IMMEDIATEDocumentation · DatabricksFreeFOR statementDocumentation · DatabricksFreeFETCH statementDocumentation · DatabricksFreeGET DIAGNOSTICS statementDocumentation · DatabricksFreeHome - The Internals of Spark SQLBook · Jacek Laskowski · checked 10 Sept 2026FreeDatabricks SQL language referenceDocumentation · Databricks · checked 10 Sept 2026FreeSELECT (subselect)Documentation · Databricks · checked 10 Sept 2026FreeIdentifiersDocumentation · Databricks · checked 10 Sept 2026FreeANSI compliance in Databricks RuntimeDocumentation · Databricks · checked 10 Sept 2026FreeUSE DATABASEDocumentation · Databricks · checked 10 Sept 2026FreeData typesDocumentation · Databricks · checked 10 Sept 2026Freecast functionDocumentation · Databricks · checked 10 Sept 2026FreeDECIMAL typeDocumentation · Databricks · checked 10 Sept 2026FreeJOINDocumentation · Databricks · checked 10 Sept 2026FreeSet operatorsDocumentation · Databricks · checked 10 Sept 2026FreeHintsDocumentation · Databricks · checked 10 Sept 2026FreeMERGE INTODocumentation · Databricks · checked 10 Sept 2026FreeSelectively overwrite data with Delta LakeDocumentation · Databricks · checked 10 Sept 2026FreeDeletion vectors in DatabricksDocumentation · Databricks · checked 10 Sept 2026FreeWhat is Delta Lake in Databricks?Documentation · Databricks · checked 10 Sept 2026FreeWindow functionsDocumentation · Databricks · checked 10 Sept 2026FreeQUALIFY clauseDocumentation · Databricks · checked 10 Sept 2026Free