Skip to content

Databricks Dialect Follow-up Clean-up#533

Merged
hadia206 merged 12 commits into
mainfrom
Hadia/db_followup
Jun 24, 2026
Merged

Databricks Dialect Follow-up Clean-up#533
hadia206 merged 12 commits into
mainfrom
Hadia/db_followup

Conversation

@hadia206

@hadia206 hadia206 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Linked ticket

Addressing comments here

Type of change

  • Bug fix
  • New feature
  • Refactor
  • Docs / config

What changed and why?

1. Drop Python 3.10

It's EOL is October 2026. Removes 3.10 from the CI matrix and pyproject.toml classifiers.

2. Update convert_sum

Four dialects (Databricks, Snowflake, Postgres, Trino) had identical convert_sum overrides that emit COUNT_IF for boolean arguments.

Moved the logic to BaseTransformBindings so all current and future dialects get it automatically.

Dialects without native COUNT_IF ave SQLGlot transpile the CountIf expression to the correct equivalent:

  • SQLite: SUM(IIF ..., 1, 0)
  • Postgres: SUM(CASE WHEN … THEN 1 ELSE 0 END)
  • Needed to add explicit conver_sum for MySQL and Oracle because SqlGlot didn't transpile them correctly. They generate SUM(expr)

Reference SQL files regenerated accordingly.

3. Simplify tpch q16 params test

Consolidate params tests 6 per-dialect params fixtures/tests replaced by single all_dialects_params_tpch_db_context fixture and one test_pipeline_e2e_tpch_params in test_pipeline_tpch.py

4. SQLGlot Transpile Snowfalke to Databricks Investigation for databricks_task.py

Investigated whether SQLGlot's Snowflake -> Databricks transpile could replace the regex-based adaptations in databricks_task.py ( adapt_for_databricks and _adapt_create_table).
Short answer: no. See table below for details

Pattern Context SQLGlot result Verdict
TEXTSTRING CREATE TABLE Correct
NUMERIC(p,s)DECIMAL(p,s) CREATE TABLE Correct
UNIQUE stripped CREATE TABLE Dropped
DEFAULT CURRENT_TIMESTAMPDEFAULT CURRENT_TIMESTAMP() CREATE TABLE Valid for Databricks
'x'::timestampCAST('x' AS TIMESTAMP) DML Valid (differs from current TIMESTAMP 'x' but both work)
INTERVAL 'N unit'INTERVAL 'N' UNIT DML Valid (quoted number, Databricks accepts)
PRIMARY KEY stripped CREATE TABLE Kept; standalone form gets invalid NULLS LAST
AUTOINCREMENT removed CREATE TABLE Becomes AUTO_INCREMENT (not supported in Databricks)
REFERENCES stripped CREATE TABLE Kept
IF NOT EXISTS added CREATE TABLE Not added
defog.<schema>.table prefix added CREATE TABLE Not added
USING DELTA TBLPROPERTIES(...) appended CREATE TABLE Not added
EXTRACT(EPOCH FROM …)UNIX_TIMESTAMP(…) DML Left unchanged
TO_CHAR(…)DATE_FORMAT(…) DML Left unchanged
DEFOG.SCHEMA.TABLEdefog.schema.table lowercasing DML Not done
Mixed DATE/TIMESTAMP in INSERT VALUES normalized DML Not handled

How I tested this?

  • PR testing CI

Notes for reviewers

  • The failed Oracle test is unrelated and fixed by John in this PR
  • The failed BodoSQL tests are related to recent Bodo engine version and is being investigated by the team.

@hadia206 hadia206 marked this pull request as ready for review June 22, 2026 20:21
@hadia206 hadia206 requested review from john-sanchez31 and knassre-bodo and removed request for knassre-bodo June 23, 2026 17:15

@knassre-bodo knassre-bodo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor comment, otherwise LGTM :)

Comment thread tests/conftest.py Outdated
Comment on lines +792 to +798
pytest.param(
"databricks",
id="databricks",
marks=[pytest.mark.databricks],
),
],
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this a common parameterized fixture that is shared as an input between all_dialects_params_tpch_db_context and all_dialects_tpch_db_context.

@john-sanchez31 john-sanchez31 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Btw, the fix for the Oracle test it's in main

@hadia206 hadia206 merged commit f158a45 into main Jun 24, 2026
27 checks passed
@hadia206 hadia206 deleted the Hadia/db_followup branch June 24, 2026 18:19
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.

3 participants