Skip to content

TSQL Convert #514

Closed Answered by georgesittas
TimothyAerts asked this question in Q&A
Sep 30, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hello,

This has already been fixed in the main branch (see here). Make sure you're using T-SQL as the input dialect in the parser.

Regarding your examples:

>>> sqlglot.parse_one("SELECT CONVERT(DATE, '2017-08-29')", read='tsql')
(SELECT expressions:
  (CAST this:
    (LITERAL this: 2017-08-29, is_string: True), to:
    (DATATYPE this: Type.DATE, nested: False)))

>>> sqlglot.parse_one("SELECT CONVERT(int, 25.65)", read='tsql')
(SELECT expressions:
  (CAST this:
    (LITERAL this: 25.65, is_string: False), to:
    (DATATYPE this: Type.INT, nested: False)))

Or would it be preferred to overwrite the parse_convert specifically for the tsql dialect?

When it comes to changes like this, it's u…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@TimothyAerts
Comment options

Answer selected by TimothyAerts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants