diff --git a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxConnector.cpp b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxConnector.cpp index 38c8e785663a..e370ebdd45d5 100644 --- a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxConnector.cpp +++ b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxConnector.cpp @@ -1409,12 +1409,18 @@ IcebergPrestoToVeloxConnector::toVeloxColumnHandle( // TODO(imjalpreet): Modify 'hiveType' argument of the 'HiveColumnHandle' // constructor similar to how Hive Connector is handling for bucketing velox::type::fbhive::HiveTypeParser hiveTypeParser; + auto type = stringToType(icebergColumn->type, typeParser); + connector::hive::HiveColumnHandle::ColumnParseParameters columnParseParameters; + if (type->isDate()) { + columnParseParameters.partitionDateValueFormat = connector::hive::HiveColumnHandle::ColumnParseParameters::kDaysSinceEpoch; + } return std::make_unique( icebergColumn->columnIdentity.name, toHiveColumnType(icebergColumn->columnType), - stringToType(icebergColumn->type, typeParser), - stringToType(icebergColumn->type, typeParser), - toRequiredSubfields(icebergColumn->requiredSubfields)); + type, + type, + toRequiredSubfields(icebergColumn->requiredSubfields), + columnParseParameters); } std::unique_ptr diff --git a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeIcebergGeneralQueries.java b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeIcebergGeneralQueries.java index 45f6613f41e9..59ce312ce458 100644 --- a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeIcebergGeneralQueries.java +++ b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/TestPrestoNativeIcebergGeneralQueries.java @@ -41,16 +41,24 @@ protected ExpectedQueryRunner createExpectedQueryRunner() @Override protected void createTables() { - createTableToTestHiddenColumns(); + createTestTables(); } - private void createTableToTestHiddenColumns() + private void createTestTables() { QueryRunner javaQueryRunner = ((QueryRunner) getExpectedQueryRunner()); - if (!javaQueryRunner.tableExists(getSession(), "test_hidden_columns")) { - javaQueryRunner.execute("CREATE TABLE test_hidden_columns AS SELECT * FROM tpch.tiny.region WHERE regionkey=0"); - javaQueryRunner.execute("INSERT INTO test_hidden_columns SELECT * FROM tpch.tiny.region WHERE regionkey=1"); - } + + javaQueryRunner.execute("DROP TABLE IF EXISTS test_hidden_columns"); + javaQueryRunner.execute("CREATE TABLE test_hidden_columns AS SELECT * FROM tpch.tiny.region WHERE regionkey=0"); + javaQueryRunner.execute("INSERT INTO test_hidden_columns SELECT * FROM tpch.tiny.region WHERE regionkey=1"); + + javaQueryRunner.execute("DROP TABLE IF EXISTS ice_table_partitioned"); + javaQueryRunner.execute("CREATE TABLE ice_table_partitioned(c1 INT, ds DATE) WITH (partitioning = ARRAY['ds'])"); + javaQueryRunner.execute("INSERT INTO ice_table_partitioned VALUES(1, date'2022-04-09'), (2, date'2022-03-18'), (3, date'1993-01-01')"); + + javaQueryRunner.execute("DROP TABLE IF EXISTS ice_table"); + javaQueryRunner.execute("CREATE TABLE ice_table(c1 INT, ds DATE)"); + javaQueryRunner.execute("INSERT INTO ice_table VALUES(1, date'2022-04-09'), (2, date'2022-03-18'), (3, date'1993-01-01')"); } @Test @@ -94,4 +102,11 @@ public void testDataSequenceNumberHiddenColumn() .getOnlyValue(), 0L); } + + @Test + public void testDateQueries() + { + assertQuery("SELECT * FROM ice_table_partitioned WHERE ds >= date'1994-01-01'", "VALUES (1, date'2022-04-09'), (2, date'2022-03-18')"); + assertQuery("SELECT * FROM ice_table WHERE ds = date'2022-04-09'", "VALUES (1, date'2022-04-09')"); + } }