Skip to content

Support TRUNCATE IF EXISTS, STRUCT-field COLLATE, and Delta time travel - #89

Merged
lustefaniak merged 3 commits into
mainfrom
lukasz-truncate-if-exists
Jun 18, 2026
Merged

Support TRUNCATE IF EXISTS, STRUCT-field COLLATE, and Delta time travel#89
lustefaniak merged 3 commits into
mainfrom
lukasz-truncate-if-exists

Conversation

@lustefaniak

Copy link
Copy Markdown
Collaborator

Three independent dialect parser fixes (one per commit), each with tests and verified against the corpus (0 regressions).

  • fix(snowflake): support TRUNCATE IF EXISTS — accept the optional IF EXISTS clause in TRUNCATE [TABLE] [IF EXISTS] <name> (Snowflake docs). Captured via a new if_exists flag on Statement::Truncate.
  • fix(databricks): accept COLLATE on STRING fields inside STRUCT — consume the per-field COLLATE <name> clause on string types nested in STRUCT<...> / ARRAY<STRUCT<...>> (collation docs). Collation carries no lineage so it is consumed but not retained. Fixes 2 corpus files.
  • fix(databricks): parse Delta Lake time-travel qualifiers — support VERSION AS OF <version>, TIMESTAMP AS OF <expr>, and the @v<version> / @<yyyyMMddHHmmssSSS> shorthands in both pre-alias and post-alias positions (time travel docs). Captured on the AST via two new TableVersion variants. Fixes 1 real customer corpus file.

All 1186 unit tests pass; corpus comparison shows 0 regressions.

Snowflake accepts an optional IF EXISTS clause in
TRUNCATE [TABLE] [IF EXISTS] <name>
(https://docs.snowflake.com/en/sql-reference/sql/truncate-table). Parse and
round-trip it via a new if_exists flag on Statement::Truncate; previously the
clause errored with "Expected end of statement, found: EXISTS".
Databricks permits a per-field COLLATE clause on string types in column,
field, or variable type definitions, including fields nested inside STRUCT and
ARRAY<STRUCT<...>>
(https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-collation).
Consume the optional COLLATE name in the STRUCT field-definition parser; the
collation carries no lineage so it is not retained in the AST.
Fixes 2 corpus test failures (Databricks).
Support Delta Lake / Databricks time travel on table references:
VERSION AS OF <version>, TIMESTAMP AS OF <expr>, and the @v<version> /
@<yyyyMMddHHmmssSSS> shorthands, in both the pre-alias and post-alias
positions (https://docs.databricks.com/aws/en/delta/history). The qualifier is
captured on the AST via two new TableVersion variants (VersionAsOf,
TimestampAsOf); the table name is unaffected so lineage is preserved. The @
shorthands canonicalize to the AS OF forms on display.
Fixes 1 corpus test failure (Databricks).
@github-actions

Copy link
Copy Markdown

Corpus Parsing Report

Total: 191711 passed, 1920 failed (99.0% pass rate)

✨ No changes in test results

By Dialect

DialectPassedFailedTotalPass RateDelta
ansi5116958088.1%-
athena3713897.4%-
bigquery423241134243799.7%-
clickhouse2723129285295.5%-
databricks2965184314994.2%+3
doris28124070.0%-
dremio27027100.0%-
duckdb112445116996.2%-
exasol5476188.5%-
fabric606100.0%-
generic17385530.9%-
hive35104577.8%-
materialize6142030.0%-
mssql2276407268384.8%-
mysql1513718880.3%-
oracle1046352139874.8%-
postgres1172111128391.3%-
presto5586387.3%-
redshift40503654056899.8%-
singlestore141915094.0%-
snowflake947391389487799.9%-
spark902011081.8%-
sqlite51166776.1%-
starrocks2943387.9%-
teradata23204353.5%-
trino141377149094.8%-
tsql1653419982.9%-

@lustefaniak
lustefaniak enabled auto-merge (rebase) June 18, 2026 00:54
@lustefaniak
lustefaniak merged commit 6b95571 into mainJun 18, 2026
3 checks passed
@lustefaniak
lustefaniak deleted the lukasz-truncate-if-exists branch June 18, 2026 07:17
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lustefaniak@grasskode