← Back
Databricks SQL 2025.40 introduces SQL scripting GA and expanded parameter markers
· releasefeatureapi · docs.databricks.com ↗

SQL Scripting Now Generally Available

SQL scripting is now generally available in Databricks SQL, enabling developers to write procedural logic directly in SQL. This includes conditional statements, loops, local variables, and exception handling—expanding SQL beyond traditional declarative queries into a full procedural language.

Enhanced Parameterization Support

Parameter markers are now supported in nearly all SQL contexts where literal values are allowed:

  • DDL statements: CREATE VIEW v AS SELECT ? AS c1
  • Column type definitions: DECIMAL(:p, :s)
  • Comments: COMMENT ON t IS :comment

The IDENTIFIER clause has been expanded to support dynamic object naming in additional contexts, including column aliases and definitions: AS IDENTIFIER(:name) and IDENTIFIER(:pk) BIGINT NOT NULL.

Literal string coalescing now works everywhere string literals are permitted, allowing sequential strings like 'Hello' ' World' to automatically combine into 'Hello World'.

New Approximate Computation Functions

Two major function libraries have been added for statistical operations:

  • Theta Sketch functions for approximate distinct counts and set operations: theta_sketch_agg, theta_union_agg, theta_intersection_agg, and supporting functions
  • KLL Sketch functions for approximate quantile computation with variants for BIGINT, DOUBLE, and FLOAT types, including aggregation, merging, and retrieval functions

Additionally, a new BITMAP_AND_AGG function complements the existing bitmap function library for bit-level operations.

Action Items

Existing SQL code can take advantage of parameterization features to improve security and reusability. Teams working with approximate analytics should evaluate the new Theta Sketch and KLL Sketch functions for performance optimization on large datasets.