-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Athena Iceberg Tables parsing issue #3126
Comments
I have tested this and is does not seem to have made a difference. In [14]: sqlglot.__version__
Out[14]: '22.4.0' Input SQL: create table if not exists tmp.mytable (
name string
)
location 's3://bucket/tmp/mytable/'
tblproperties (
'table_type'='iceberg',
'format'='parquet'
); Output: In [13]: sqlglot.parse(sql, read=sqlglot.Dialects.ATHENA)[0].sql()
Out[13]: "CREATE TABLE IF NOT EXISTS tmp.mytable (name TEXT) LOCATION 's3://bucket/tmp/mytable/' WITH (table_type='iceberg', FORMAT='parquet')" |
You need to specify the output dialect: >>> sql = """
... create table if not exists tmp.mytable (
... name string
... )
... location 's3://bucket/tmp/mytable/'
... tblproperties (
... 'table_type'='iceberg',
... 'format'='parquet'
... );
... """
>>>
>>> import sqlglot
>>>
>>> sqlglot.parse_one(sql, dialect="athena").sql(dialect="athena") # or just sqlglot.transpile(sql, read="athena")[0]
"CREATE TABLE IF NOT EXISTS tmp.mytable (name STRING) LOCATION 's3://bucket/tmp/mytable/' TBLPROPERTIES ('table_type'='iceberg', 'FORMAT'='parquet')" |
Ah, thanks. I missed that! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I want to parse a SQL Statement that creates an Iceberg table on Athena:
running
returns:
Unfortunately, the syntax in Athena is different for Iceberg Tables and Hive-style tables.
The parsed statement should look like this:
Instead of WITH -> TBLPROPERTIES
The keys in the this block are wrapped in upper quotes and iceberg has slightly different data types. In this case STRING instead of TEXT
https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg-supported-data-types.html
https://docs.aws.amazon.com/athena/latest/ug/querying-iceberg-creating-tables.html
The text was updated successfully, but these errors were encountered: