TSQL Convert #514
-
Hi, First of all many thanks for this library, what an awesome tool! The problematic part in the current parse convert implementation is that the datatype in the tsql case is now parsed as an ID_VAR_TYPE instead of a datatype. Then the subsequent token that is the actual ID_VAR is not able to parse since the match fails. What would be the preferable solution here? Any other suggestions are more than welcome. Kind regards, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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)))
When it comes to changes like this, it's usually better to do the overwriting only for the target dialect, although this might not be the case if there are several dialects that can benefit from them. |
Beta Was this translation helpful? Give feedback.
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:
When it comes to changes like this, it's u…