Type Annotation Discrepancy: Generic vs. Dialect-Specific Types #5482
-
@tobymao The Problem: While the type annotation process correctly identifies the base type (e.g., My Goal: I want the annotated type's Example: Given the following schema and SQL query: schema = {
'customers': {
'customerid': DataType(this=Type.INT, nested=False),
# ... other columns
}
}
sql_query = """
SELECT
[customers].[customerid] AS [customerid]
FROM [customers] AS [customers]
"""
dialect = 'tsql' After annotation: annotated_exprs = annotate_types(expression=ast, schema=schema, dialect="tsql")
annotated_exprs.expressions[0].type.this
# Current Result: <Type.INT: 'INT'>
# Desired Result: 'INTEGER' (or similar T-SQL specific representation) Question: Is it possible to configure or extend the Any guidance or examples would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You can get the dialect-specific name by generating SQL for the annotated type targeting said dialect: annotated_exprs = annotate_types(expression=ast, schema=schema, dialect="tsql")
annotated_exprs.expressions[0].type.sql("tsql") The current AST structure is expected. We intentionally don't tie any transformations or ASTs to a specific dialect. |
Beta Was this translation helpful? Give feedback.
You can get the dialect-specific name by generating SQL for the annotated type targeting said dialect:
The current AST structure is expected. We intentionally don't tie any transformations or ASTs to a specific dialect.