Skip to content

feat(databricks): convert more functions, collations, GROUP BY positions and pipelines - #344

Queued
kvlonge wants to merge 27 commits into
mainfrom
feat/databricks-functions-2
Queued

kvlonge wants to merge 27 commits into
mainfrom
feat/databricks-functions-2

Conversation

@kvlonge

@kvlonge kvlonge commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Why

More Databricks functions and expressions can convert where recorded Databricks results prove the rule. This moves 19 forms to matching (497 to 516, 9 within ULP unchanged), none lost.

Changes

  • GROUPING and GROUPING_ID, COUNTER_DIFF (raising for a negative counter), ANY_VALUE as FIRST under first_last_order.
  • IN and NOT IN a subquery as coalesce(..., false), as recorded; NOT of NOT IN refuses. DECODE's key/result form as a CASE on IS NOT DISTINCT FROM.
  • HASH, XXHASH64, HMAC and CRC32; BITMAP_CONSTRUCT_AGG; TIME_DIFF of a literal unit; FORMAT_NUMBER of integers and decimals; SEARCH and ISEARCH in substring mode; DATE_FORMAT of a TIME.
  • TIME 'HH:MM' literals; RANGE frame offsets over one integer key; ORDER BY under UTF8_LCASE and UTF8_BINARY, comparisons under UTF8_BINARY.
  • GROUP BY n reads the nth output; TABLE t |> ... pipelines; SEQUENCE of a STRING bound beside an integer; CAST(DECIMAL AS BIGINT) truncates; VECTOR_L2_DISTANCE.
  • CONV and FORMAT_NUMBER of a DOUBLE now refuse: Java's Double.toString writes some values differently.
  • declared-refusals.toml lists the 27 statements six loud divergences raise on; not-translatable.toml gains MATCH_RECOGNIZE (DuckDB has no row-pattern matching) and CURRENT_TIMEZONE (session-dependent). All unsigned until reviewed.
  • Statement refusals in convert are worded for scripts.
  • The evidence pin moves to the commit holding the new hand cases and their recordings.

Verification

  • sqlbabel verify on the pinned evidence: 3133 passed, 27 diverged as expected, 0 failed, 0 unproven. syntax-coverage results holds the new baseline with no regression.
  • Unit tests for the Databricks converter and policy. CLI tests run the converted SQL on DuckDB and check the recorded values.
  • make check-ci and the hygiene scan pass.

…_VALUE and IN a subquery

Incomplete: no CLI tests yet, form-links sign-off not refreshed, evidence not pinned.
…over one integer key and ORDER BY under UTF8_LCASE

ARRAY_SORT with a comparator refuses as the function, a window with a
written frame links to the frame form, and the grouping and unit
helpers return their refusals instead of probing with ok().
…egative COUNTER_DIFF counter and cap integer places at 340

The recordings show Databricks reading a DOUBLE's digits from Java's
Double.toString, which writes 1e23 as 9.999999999999999E22, rejecting a
negative counter with COUNTER_DIFF_NEGATIVE_COUNTER_VALUE, and writing
at most 340 fraction digits of an integer.
DECODE with key/result pairs converts to a CASE on IS NOT DISTINCT FROM
when the keys match the value type and the results share a type. NOT IN
a subquery converts as coalesce(x NOT IN (subquery), false), matching the
recorded behaviour where NULL reads as false; NOT of NOT IN refuses.
A comparison operand under COLLATE UTF8_BINARY compares as the plain
string, byte by byte. A collated value elsewhere refuses, because Databricks
types it STRING COLLATE name; ORDER BY and comparisons share one reading of
the collation clause.
GROUP BY n groups by the nth output, as Databricks reads an integer key.
A position past the outputs or naming an aggregate converts as the
rejection Databricks raises.
TABLE t reads every column of t, as SELECT * FROM t does, so a pipeline
starting with it converts as one starting FROM t.
…IGINT

Databricks casts a STRING start or stop beside an integer one to BIGINT,
trimming spaces and raising for text that is no whole number, and returns
ARRAY<BIGINT>. Two STRING bounds stay refused, as Databricks rejects them.
Databricks drops the fraction where DuckDB rounds it. A DECIMAL with at
most 18 whole digits converts as CAST(trunc(x) AS BIGINT); a wider one
stays refused, as its overflow is unrecorded.
The distance sums squared DOUBLE differences in blocks of eight, as the
inner product does, and narrows the root to FLOAT as Java does. The
recordings, including long vectors, match. VECTOR_NORMALIZE stays refused,
as no rule writes its FLOAT array result as Databricks returns it.
…on cases

Pins the evidence commit with the DECODE, IN subquery, collation, GROUP BY
position, SEQUENCE, cast, vector, pipeline and MATCH_RECOGNIZE cases, and
regenerates the obligations, recorded rejections and results baseline.
…fuse

Lists, one group per divergence, the 27 recorded statements where the
converted SQL raises rather than return a value Databricks may not: FIRST,
LAST and ANY_VALUE order, COLLECT_LIST order, DOUBLE sum order, regex
column patterns, odd hex in TO_BINARY and URL_DECODE of invalid UTF-8.
The groups count only once a reviewer signs them off.
… pipelines, SEQUENCE, casts and vector distance end to end

Converts each through the convert command and runs it on DuckDB, checking
the value Databricks recorded.
… shows

DECODE of integer results with a default refuses: Databricks types it INT,
not the BIGINT recorded without a default. RANGE offsets convert only over
INT and BIGINT keys, as Databricks adds the offset in the key type where
DuckDB widens a smaller one. ISEARCH raises for a target holding capital I
with dot above when its pattern could match half of that letter's lower
case. Also names the xxHash64 accumulators as such and builds the
COUNTER_DIFF raise in one format call.
…slatable

DuckDB has no row-pattern matching, and CURRENT_TIMEZONE returns the
session's zone, which no literal converts for every session. Both groups
count only once a reviewer signs them off; their recorded cases stay.
@kvlonge
kvlonge enabled auto-merge November 30, 2026 13:17
@kvlonge kvlonge closed this Nov 30, 2026
auto-merge was automatically disabled November 30, 2026 14:57

Pull request was closed

@kvlonge kvlonge reopened this Nov 30, 2026
@kvlonge
kvlonge enabled auto-merge November 30, 2026 14:57
@kvlonge
kvlonge added this pull request to the merge queue Nov 30, 2026
Any commits made after this event will not be merged.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant