summaryrefslogtreecommitdiffstats
path: root/tests/dialects/test_athena.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/dialects/test_athena.py')
-rw-r--r--tests/dialects/test_athena.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/dialects/test_athena.py b/tests/dialects/test_athena.py
index ef96938..c5ba4cc 100644
--- a/tests/dialects/test_athena.py
+++ b/tests/dialects/test_athena.py
@@ -198,7 +198,8 @@ class TestAthena(Validator):
def test_ctas(self):
# Hive tables use 'external_location' to specify the table location, Iceberg tables use 'location' to specify the table location
- # The 'table_type' property is used to determine if it's a Hive or an Iceberg table
+ # In addition, Hive tables used 'partitioned_by' to specify the partition fields and Iceberg tables use 'partitioning' to specify the partition fields
+ # The 'table_type' property is used to determine if it's a Hive or an Iceberg table. If it's omitted, it defaults to Hive
# ref: https://docs.aws.amazon.com/athena/latest/ug/create-table-as.html#ctas-table-properties
ctas_hive = exp.Create(
this=exp.to_table("foo.bar"),
@@ -207,13 +208,16 @@ class TestAthena(Validator):
expressions=[
exp.FileFormatProperty(this=exp.Literal.string("parquet")),
exp.LocationProperty(this=exp.Literal.string("s3://foo")),
+ exp.PartitionedByProperty(
+ this=exp.Schema(expressions=[exp.to_column("partition_col")])
+ ),
]
),
expression=exp.select("1"),
)
self.assertEqual(
ctas_hive.sql(dialect=self.dialect, identify=True),
- "CREATE TABLE \"foo\".\"bar\" WITH (format='parquet', external_location='s3://foo') AS SELECT 1",
+ "CREATE TABLE \"foo\".\"bar\" WITH (format='parquet', external_location='s3://foo', partitioned_by=ARRAY['partition_col']) AS SELECT 1",
)
ctas_iceberg = exp.Create(
@@ -223,11 +227,14 @@ class TestAthena(Validator):
expressions=[
exp.Property(this=exp.var("table_type"), value=exp.Literal.string("iceberg")),
exp.LocationProperty(this=exp.Literal.string("s3://foo")),
+ exp.PartitionedByProperty(
+ this=exp.Schema(expressions=[exp.to_column("partition_col")])
+ ),
]
),
expression=exp.select("1"),
)
self.assertEqual(
ctas_iceberg.sql(dialect=self.dialect, identify=True),
- "CREATE TABLE \"foo\".\"bar\" WITH (table_type='iceberg', location='s3://foo') AS SELECT 1",
+ "CREATE TABLE \"foo\".\"bar\" WITH (table_type='iceberg', location='s3://foo', partitioning=ARRAY['partition_col']) AS SELECT 1",
)