diff --git a/spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 193dc13dc29b..3e0452d94ac5 100644 --- a/spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.1/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -421,17 +421,21 @@ public static PartitionSpec toPartitionSpec(Schema schema, Transform[] partition case "bucket": builder.bucket(colName, findWidth(transform)); break; + case "year": case "years": builder.year(colName); break; + case "month": case "months": builder.month(colName); break; case "date": + case "day": case "days": builder.day(colName); break; case "date_hour": + case "hour": case "hours": builder.hour(colName); break; diff --git a/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java b/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java index 1411c83ddc65..a6256afcdf65 100644 --- a/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java +++ b/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java @@ -63,6 +63,26 @@ public void testTransformIgnoreCase() { Assert.assertTrue("Table should already exist", validationCatalog.tableExists(tableIdent)); } + @Test + public void testTransformSingularForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hour(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + + @Test + public void testTransformPluralForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hours(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + @Test public void testCreateTable() { Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); diff --git a/spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 0a6a893f9ebf..c5c7ee4d53d7 100644 --- a/spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -403,17 +403,21 @@ public static PartitionSpec toPartitionSpec(Schema schema, Transform[] partition case "bucket": builder.bucket(colName, findWidth(transform)); break; + case "year": case "years": builder.year(colName); break; + case "month": case "months": builder.month(colName); break; case "date": + case "day": case "days": builder.day(colName); break; case "date_hour": + case "hour": case "hours": builder.hour(colName); break; diff --git a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java index 1411c83ddc65..a6256afcdf65 100644 --- a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java +++ b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java @@ -63,6 +63,26 @@ public void testTransformIgnoreCase() { Assert.assertTrue("Table should already exist", validationCatalog.tableExists(tableIdent)); } + @Test + public void testTransformSingularForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hour(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + + @Test + public void testTransformPluralForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hours(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + @Test public void testCreateTable() { Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); diff --git a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 0ed90e9455e2..2f04ae374951 100644 --- a/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -420,17 +420,21 @@ public static PartitionSpec toPartitionSpec(Schema schema, Transform[] partition case "bucket": builder.bucket(colName, findWidth(transform)); break; + case "year": case "years": builder.year(colName); break; + case "month": case "months": builder.month(colName); break; case "date": + case "day": case "days": builder.day(colName); break; case "date_hour": + case "hour" case "hours": builder.hour(colName); break; diff --git a/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java b/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java index 1411c83ddc65..a6256afcdf65 100644 --- a/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java +++ b/spark/v3.3/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java @@ -63,6 +63,26 @@ public void testTransformIgnoreCase() { Assert.assertTrue("Table should already exist", validationCatalog.tableExists(tableIdent)); } + @Test + public void testTransformSingularForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hour(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + + @Test + public void testTransformPluralForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hours(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + @Test public void testCreateTable() { Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); diff --git a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index becea88bf167..62301e9676b8 100644 --- a/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.4/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -429,17 +429,21 @@ public static PartitionSpec toPartitionSpec(Schema schema, Transform[] partition case "bucket": builder.bucket(colName, findWidth(transform)); break; + case "year": case "years": builder.year(colName); break; + case "month": case "months": builder.month(colName); break; case "date": + case "day": case "days": builder.day(colName); break; case "date_hour": + case "hour": case "hours": builder.hour(colName); break; diff --git a/spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java b/spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java index 01b8b99062a0..ecfd6759b900 100644 --- a/spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java +++ b/spark/v3.4/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java @@ -63,6 +63,26 @@ public void testTransformIgnoreCase() { Assert.assertTrue("Table should already exist", validationCatalog.tableExists(tableIdent)); } + @Test + public void testTransformSingularForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hour(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + + @Test + public void testTransformPluralForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hours(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + @Test public void testCreateTable() { Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); diff --git a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java index 0fabffc8950d..cfcc3941c748 100644 --- a/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java +++ b/spark/v3.5/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java @@ -429,17 +429,21 @@ public static PartitionSpec toPartitionSpec(Schema schema, Transform[] partition case "bucket": builder.bucket(colName, findWidth(transform)); break; + case "year": case "years": builder.year(colName); break; + case "month": case "months": builder.month(colName); break; case "date": + case "day": case "days": builder.day(colName); break; case "date_hour": + case "hour": case "hours": builder.hour(colName); break; diff --git a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java index 01b8b99062a0..ecfd6759b900 100644 --- a/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java +++ b/spark/v3.5/spark/src/test/java/org/apache/iceberg/spark/sql/TestCreateTable.java @@ -63,6 +63,26 @@ public void testTransformIgnoreCase() { Assert.assertTrue("Table should already exist", validationCatalog.tableExists(tableIdent)); } + @Test + public void testTransformSingularForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hour(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + + @Test + public void testTransformPluralForm() { + Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent)); + sql( + "CREATE TABLE IF NOT EXISTS %s (id BIGINT NOT NULL, ts timestamp) " + + "USING iceberg partitioned by (hours(ts))", + tableName); + Assert.assertTrue("Table should exist", validationCatalog.tableExists(tableIdent)); + } + @Test public void testCreateTable() { Assert.assertFalse("Table should not already exist", validationCatalog.tableExists(tableIdent));