Skip to content

feat(go): use updated split_statement with sqlglot#46

Merged
lidavidm merged 1 commit into
adbc-drivers:mainfrom
Mandukhai-Alimaa:feat/use-updated-split-statement
Jan 7, 2026
Merged

feat(go): use updated split_statement with sqlglot#46
lidavidm merged 1 commit into
adbc-drivers:mainfrom
Mandukhai-Alimaa:feat/use-updated-split-statement

Conversation

@Mandukhai-Alimaa

@Mandukhai-Alimaa Mandukhai-Alimaa commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

What's Changed

remove override of split_statement.

Had to update the INSERT statements to explicitly define TIME(6) precision. Without it, SQLGlot was parsing the SQL as a generic CAST(x AS TIME). Because the precision wasn't specified in the parsed SQL, the database interpreted the value using its default time precision (3), causing it to round '23:59:59.999999' up to '24:00:00'. Adding the explicit precision ensures the parsed SQL tells the database to preserve all fractional digits.

@lidavidm lidavidm 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.

Is that worth filing a bug with sqlglot? If Trino defaults to TIME(6) then I suppose sqlglot should too.

@lidavidm
lidavidm merged commit 5ae2772 into adbc-drivers:main Jan 7, 2026
13 checks passed
@Mandukhai-Alimaa

Copy link
Copy Markdown
Contributor Author

It's not a bug. Trino defaults to TIME(3), not TIME(6). The issue is that Trino behaves differently depending on the SQL syntax. When we write a direct TIME literal like INSERT INTO test_time VALUES (TIME '23:59:59.999999'), Trino can see we are inserting into a TIME(6) column and preserves all 6 fractional digits. However, when we write INSERT INTO test_time VALUES (CAST('23:59:59.999999' AS TIME)), Trino evaluates the CAST first before knowing anything about the target column. It defaults to TIME(3), which rounds 23:59:59.999999 to 23:59:59.999, then to 24:00:00, which overflows to 00:00:00.

The problem occurs because SQLGlot doesn't know the database schema, so when it parses TIME '23:59:59.999999', it translates it to a generic CAST('23:59:59.999999' AS TIME). When Trino receives this generated SQL, it evaluates the CAST independently and applies its TIME(3) default, causing the overflow to midnight. By explicitly specifying TIME(6) precision in the insert statement, SQLGlot can generate the vendor-specific SQL with the correct precision as CAST('23:59:59.999999' AS TIME(6)), which tells Trino to preserve all fractional digits.

@lidavidm

lidavidm commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Ah, thanks, good to know.

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.

2 participants