Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
092b542
wip: convert GROUPING, GROUPING_ID, COUNTER_DIFF, CONV of DOUBLE, ANY…
kvlonge Nov 30, 2026
782c079
wip: convert Databricks FORMAT_NUMBER for integers, decimals and name…
kvlonge Nov 30, 2026
049d310
wip: convert Databricks HMAC, CRC32, HASH and XXHASH64 in DuckDB inte…
kvlonge Nov 30, 2026
7bec7fc
wip: convert Databricks BITMAP_CONSTRUCT_AGG and read INVALID_BITMAP_…
kvlonge Nov 30, 2026
a2eab96
wip: convert Databricks TIME_DIFF of a literal unit and test CONV ref…
kvlonge Nov 30, 2026
38c4aaa
wip: convert Databricks VECTOR_L2_DISTANCE and VECTOR_NORMALIZE in DO…
kvlonge Nov 30, 2026
a6d456f
Revert "wip: convert Databricks VECTOR_L2_DISTANCE and VECTOR_NORMALI…
kvlonge Nov 30, 2026
2e32b02
wip: word Databricks statement refusals for scripts converted from th…
kvlonge Nov 30, 2026
6a5fca0
wip: refuse Databricks TIME_DIFF of a bare unit keyword as the reject…
kvlonge Nov 30, 2026
c9a5436
wip: convert Databricks TIME literals without seconds, RANGE offsets …
kvlonge Nov 30, 2026
6c28bd8
wip: show the reworded statement refusal in the convert example
kvlonge Nov 30, 2026
0de6815
wip: convert Databricks DATE_FORMAT of a TIME under a pattern of the …
kvlonge Nov 30, 2026
51337e6
wip: convert Databricks SEARCH and ISEARCH in substring mode, ISEARCH…
kvlonge Nov 30, 2026
d4032e4
wip: link MATCH_RECOGNIZE statements to their clause forms and named …
kvlonge Nov 30, 2026
99abb8e
wip: refuse Databricks CONV and FORMAT_NUMBER of a DOUBLE, reject a n…
kvlonge Nov 30, 2026
c2953f9
feat(databricks): convert DECODE search form and NOT IN a subquery
kvlonge Nov 30, 2026
9bd497b
feat(databricks): compare strings under COLLATE UTF8_BINARY
kvlonge Nov 30, 2026
38a5010
feat(databricks): read an integer GROUP BY key as an output position
kvlonge Nov 30, 2026
ab0c34e
feat(databricks): convert a pipeline starting TABLE a relation
kvlonge Nov 30, 2026
f7ee385
feat(databricks): read a STRING SEQUENCE bound beside an integer as B…
kvlonge Nov 30, 2026
07e0a27
feat(databricks): cast a DECIMAL to BIGINT by truncating toward zero
kvlonge Nov 30, 2026
5e2177c
feat(databricks): convert VECTOR_L2_DISTANCE of FLOAT vectors
kvlonge Nov 30, 2026
5214621
chore(databricks): pin the evidence holding the newly recorded functi…
kvlonge Nov 30, 2026
4b48505
feat(coverage): declare the Databricks statements loud divergences re…
kvlonge Nov 30, 2026
5777a96
test(databricks): run DECODE, NOT IN, collations, GROUP BY positions,…
kvlonge Nov 30, 2026
df01e80
fix(databricks): refuse DECODE, RANGE and ISEARCH shapes no recording…
kvlonge Nov 30, 2026
5762bba
feat(coverage): declare MATCH_RECOGNIZE and CURRENT_TIMEZONE not tran…
kvlonge Nov 30, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions coverage/translation-databricks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ file lists only what differs.
- `not-translatable.toml`: forms with no meaningful DuckDB translation, in groups, each with its
reason. A group leaves the denominator only once `reviews/results.toml` signs off its reason and
forms by SHA-256.
- `declared-refusals.toml`: the statements a loud divergence makes DuckDB raise on where Databricks
returned rows, one group per divergence. A group sets its statements aside from its forms' state
only once `reviews/results.toml` signs it off as `declared-refusal:<id>`; until then those forms
stay `refused`.
- `obligations/functions.toml`: one obligation per generated type-combination, NULL-argument and
error-parity case of a live catalogue form, written from the cases' tags by
`scripts/build_translation_obligations_databricks.py`; `make translation-files` fails when the
Expand Down
72 changes: 72 additions & 0 deletions coverage/translation-databricks/declared-refusals.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Statements a declared divergence makes DuckDB raise on where Databricks returned rows, each raise
# the converted SQL's loud failure in place of a wrong value. A group sets its statements aside from
# its forms' state once a reviewer signs it off in reviews/results.toml.

[[declared]]
id = "collect-list-order"
divergence = "collect_list_order"
reason = "COLLECT_LIST and ARRAY_AGG return values in the order rows arrive, which neither engine defines; the converted SQL raises where the array holds several distinct values rather than return them in another order."
statements = [
"translation/functions/array-agg.toml#t001_types_1",
"translation/functions/array-agg.toml#t002_types_2",
"translation/functions/collect-list.toml#t001_types_1",
"translation/functions/collect-list.toml#t002_types_2",
]

[[declared]]
id = "first-last-order"
divergence = "first_last_order"
reason = "FIRST, LAST and ANY_VALUE return the value of a row neither engine orders; the converted SQL raises where the group gives several values rather than pick another one."
statements = [
"translation/functions/any-value.toml#t001_types_1",
"translation/functions/any-value.toml#t002_types_2",
"translation/functions/first-value.toml#t001_types_1",
"translation/functions/first-value.toml#t002_types_2",
"translation/functions/first.toml#t001_types_1",
"translation/functions/first.toml#t002_types_2",
"translation/functions/last-value.toml#t001_types_1",
"translation/functions/last-value.toml#t002_types_2",
"translation/functions/last.toml#t001_types_1",
"translation/functions/last.toml#t002_types_2",
]

[[declared]]
id = "float-sum-order"
divergence = "float_sum_order"
reason = "Databricks adds DOUBLE values in an order DuckDB does not share; the converted SQL raises where the order of addition could change the sum rather than return a different total."
statements = [
"translation/functions/avg.p2b.hand.toml#p001",
"translation/functions/sum.pa.hand.toml#p001",
"translation/functions/sum.pa.hand.toml#p002",
"translation/functions/sum.pa.hand.toml#p003",
"translation/functions/try-sum.pa.hand.toml#p001",
"translation/functions/try-sum.pa.hand.toml#p002",
"translation/functions/try-sum.pa.hand.toml#p003",
]

[[declared]]
id = "regex-column-pattern"
divergence = "regex_column_pattern"
reason = "Java and RE2 read some metacharacters apart; the converted SQL raises for a pattern column holding one rather than match it another way."
statements = [
"translation/functions/rlike.p2.hand.toml#p001",
"translation/functions/rlike.p2.hand.toml#p002",
"translation/functions/rlike.p2.hand.toml#p003",
"translation/functions/rlike.p2.hand.toml#p004",
]

[[declared]]
id = "to-binary-odd-hex"
divergence = "to_binary_odd_hex"
reason = "Databricks reads an odd count of hex digits in a way no rule explains; the converted SQL raises for one rather than return other bytes."
statements = [
"translation/functions/to-binary.pc.hand.toml#p003",
]

[[declared]]
id = "url-decode-invalid-utf8"
divergence = "url_decode_invalid_utf8"
reason = "Databricks decodes escapes that are not UTF-8 to the replacement character, where DuckDB's url_decode raises; the raise is the failure rather than other text."
statements = [
"translation/functions/url-decode.pb.hand.toml#p002",
]
18 changes: 18 additions & 0 deletions coverage/translation-databricks/form-links.toml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ forms = ["db.functions.in.in.syntax"]
constructs = ["node:in"]
forms = ["db.functions.in.in.syntax"]

[[link]]
constructs = ["spelling:in_subquery"]
forms = ["db.functions.in.in-2"]

[[link]]
constructs = ["node:is_null"]
forms = ["db.functions.isnullop"]
Expand Down Expand Up @@ -504,6 +508,16 @@ forms = ["db.expressions.window-functions"]
constructs = ["node:frame"]
forms = ["db.expressions.window-functions-frame"]

# MATCH_RECOGNIZE always writes its PATTERN and DEFINE, and every recorded case its MEASURES.
[[link]]
constructs = ["node:match_recognize"]
forms = ["db.query.select-match-recognize", "db.query.select-match-recognize-define", "db.query.select-match-recognize-measures", "db.query.select-match-recognize-pattern"]

# A window with a written frame.
[[link]]
constructs = ["spelling:window_frame"]
forms = ["db.expressions.window-functions-frame"]

# Ranking functions, and FIRST_VALUE and LAST_VALUE over a window, whose forms' grammar has no OVER
# and so cannot link by call shape.

Expand Down Expand Up @@ -720,6 +734,10 @@ reason = "A subquery in FROM is part of the table-reference and query grammar of
constructs = ["node:within_group"]
reason = "WITHIN GROUP belongs to the aggregate that takes it."

[[no_form]]
constructs = ["node:named_argument"]
reason = "A `name => value` argument belongs to the grammar of the function that takes it, such as SEARCH's mode."

[[no_form]]
constructs = ["node:var"]
reason = "A datetime unit keyword such as DAY or HOUR belongs to the grammar of the function that takes it, such as TIMESTAMPADD or DATEDIFF."
Expand Down
19 changes: 19 additions & 0 deletions coverage/translation-databricks/not-translatable.toml
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,22 @@ forms = [
"db.functions.current-database",
"db.functions.current-schema",
]

[[group]]
id = "row-pattern-matching"
reason = "MATCH_RECOGNIZE matches a regular expression of row patterns over ordered partitions, with CLASSIFIER and MATCH_NUMBER naming the matched variable and match. DuckDB has no row-pattern matching, and emulating it would mean writing a pattern-matching engine into the converted SQL. The recorded cases stay as evidence of Databricks's results."
forms = [
"db.functions.classifier",
"db.functions.match-number",
"db.query.select-match-recognize",
"db.query.select-match-recognize-define",
"db.query.select-match-recognize-measures",
"db.query.select-match-recognize-pattern",
]

[[group]]
id = "session-time-zone"
reason = "CURRENT_TIMEZONE returns the time zone of the Databricks session, which depends on the session rather than the query. A literal of one zone, such as the 'Etc/UTC' a default warehouse session gives, would be wrong for every session in another zone, so the value cannot be converted."
forms = [
"db.functions.current-timezone",
]
101 changes: 100 additions & 1 deletion coverage/translation-databricks/obligations/expressions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,28 @@ reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/collate-lcase.np.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.collation.order-by-collate-utf8-lcase.t002"
form = "db.expressions.collation.order-by-collate-utf8-lcase"
kind = "type_combination"
target = "STRING"
note = "ORDER BY under UTF8_LCASE over the code points it lowers otherwise than the simple mapping, and title-case and Greek letters. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/collation.lcase-special.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.collation.order-by-lower-collate.t001"
form = "db.expressions.collation.order-by-lower-collate"
kind = "type_combination"
target = "STRING"
note = "ORDER BY LOWER of a column under UTF8_BINARY. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/collation.lower-binary.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.comment.t001"
form = "db.expressions.comment"
Expand Down Expand Up @@ -410,6 +432,17 @@ reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/names.identifier-3.pe.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.names.identifier.syntax.t001"
form = "db.expressions.names.identifier.syntax"
kind = "type_combination"
target = "INT"
note = "a table read through IDENTIFIER. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/names.table-identifier.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.names.subscript.t001"
form = "db.expressions.names.subscript"
Expand Down Expand Up @@ -443,6 +476,17 @@ reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/names.column-aliases.pf.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.names.syntax.t001"
form = "db.expressions.names.syntax"
kind = "type_combination"
target = "INT"
note = "a table read by its name. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/names.table.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.null-type.t001"
form = "db.expressions.null-type"
Expand Down Expand Up @@ -590,6 +634,17 @@ required = true
id = "db.expressions.time-type.time.syntax.t001"
form = "db.expressions.time-type.time.syntax"
kind = "type_combination"
target = "TIME"
note = "a cast to TIME(3). Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/time-type.precision.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.time-type.time.syntax.t002"
form = "db.expressions.time-type.time.syntax"
kind = "type_combination"
target = "STRING"
note = "strings cast to TIME(3), with digits past the precision. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
Expand Down Expand Up @@ -777,6 +832,50 @@ required = true
id = "db.expressions.window-functions-frame.t002"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "BIGINT"
note = "a RANGE offset over a BIGINT key at its end. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/window-functions-frame.range-bigint.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.window-functions-frame.t003"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "INT"
note = "RANGE offsets over an INT key ascending and descending, and at INT's ends, where the bound passes the type. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/window-functions-frame.range-bounds.pa.hand.toml#p001"]
required = true

[[obligation]]
id = "db.expressions.window-functions-frame.t004"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "INT"
note = "RANGE offsets over an INT key ascending and descending, and at INT's ends, where the bound passes the type. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/window-functions-frame.range-bounds.pa.hand.toml#p002"]
required = true

[[obligation]]
id = "db.expressions.window-functions-frame.t005"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "INT"
note = "RANGE offsets over an INT key ascending and descending, and at INT's ends, where the bound passes the type. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
reading = "the argument types the generator read from the function's page"
cases = ["cases/translation/expressions/window-functions-frame.range-bounds.pa.hand.toml#p003"]
required = true

[[obligation]]
id = "db.expressions.window-functions-frame.t006"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "INT"
note = "a RANGE frame of one either side over ties and a NULL. Hand-written for the phase-2 recording."
catches = "the argument types read another way, or the result typed otherwise"
Expand All @@ -785,7 +884,7 @@ cases = ["cases/translation/expressions/window-functions-frame.range.pt.hand.tom
required = true

[[obligation]]
id = "db.expressions.window-functions-frame.t003"
id = "db.expressions.window-functions-frame.t007"
form = "db.expressions.window-functions-frame"
kind = "type_combination"
target = "INT, STRING, INT"
Expand Down
Loading
Loading