dramaticlly commented on code in PR #8394:
URL: https://github.com/apache/iceberg/pull/8394#discussion_r1326513355
##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRewriteDataFilesProcedure.java:
##########
@@ -763,6 +764,35 @@ public void testDefaultSortOrder() {
assertEquals("Data after compaction should not change", expectedRecords,
actualRecords);
}
+ @Test
+ public void testRewriteDataFilesWithSystemFunctions() {
+ Assumptions.assumeThat(catalogName).isNotEqualTo("spark_catalog");
+
+ sql(
+ "CREATE TABLE %s (c1 INT, c2 STRING, c3 TIMESTAMP) "
+ + "USING iceberg "
+ + "PARTITIONED BY (days(c3)) "
+ + "TBLPROPERTIES ('%s' '%s')",
+ tableName,
+ TableProperties.WRITE_DISTRIBUTION_MODE,
+ TableProperties.WRITE_DISTRIBUTION_MODE_NONE);
+
+ sql(
+ "INSERT INTO TABLE %s VALUES (0, 'data-0',
CAST('2017-11-22T09:20:44.294658+00:00' AS TIMESTAMP))",
+ tableName);
+ sql(
+ "INSERT INTO TABLE %s VALUES (1, 'data-1',
CAST('2017-11-23T03:15:32.194356+00:00' AS TIMESTAMP))",
+ tableName);
+ // Test with invalid filter column col1
+ Assertions.assertThatThrownBy(
+ () ->
+ sql(
+ "CALL %s.system.rewrite_data_files(table => '%s', where =>
'%s.system.years(c3) = 2017')",
Review Comment:
looks like comment suggest filter on column col1 but predicate in where
clause is actually on year transform of c3, just want to make sure if it's
desired
##########
spark/v3.4/spark/src/main/scala/org/apache/spark/sql/execution/datasources/SparkExpressionConverter.scala:
##########
@@ -35,7 +35,14 @@ object SparkExpressionConverter {
// Currently, it is a double conversion as we are converting Spark
expression to Spark filter
// and then converting Spark filter to Iceberg expression.
// But these two conversions already exist and well tested. So, we are
going with this approach.
- SparkFilters.convert(DataSourceStrategy.translateFilter(sparkExpression,
supportNestedPredicatePushdown = true).get)
+ DataSourceStrategy.translateFilter(sparkExpression,
supportNestedPredicatePushdown = true) match {
Review Comment:
thank you and I think it's much better than `null.get` when I saw it in my
change
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]