rdblue commented on code in PR #7886:
URL: https://github.com/apache/iceberg/pull/7886#discussion_r1264215191


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestSystemFunctionPushDownDQL.java:
##########
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.spark.extensions;
+
+import static 
org.apache.iceberg.spark.SystemFunPushDownHelper.createPartitionedTable;
+import static org.apache.iceberg.spark.SystemFunPushDownHelper.days;
+import static org.apache.iceberg.spark.SystemFunPushDownHelper.hours;
+import static org.apache.iceberg.spark.SystemFunPushDownHelper.months;
+import static org.apache.iceberg.spark.SystemFunPushDownHelper.years;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+import org.apache.iceberg.spark.SparkSQLProperties;
+import org.apache.spark.sql.Dataset;
+import org.apache.spark.sql.Row;
+import org.assertj.core.api.Assertions;
+import org.junit.After;
+import org.junit.Assume;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestSystemFunctionPushDownDQL extends SparkExtensionsTestBase {
+  public TestSystemFunctionPushDownDQL(
+      String catalogName, String implementation, Map<String, String> config) {
+    super(catalogName, implementation, config);
+  }
+
+  @Before
+  public void useCatalog() {
+    sql("USE %s", catalogName);
+  }
+
+  @After
+  public void removeTables() {
+    sql("DROP TABLE IF EXISTS %s PURGE", tableName);
+  }
+
+  @Test
+  public void testYearsFunction() {
+    Assume.assumeTrue(!catalogName.equals("spark_catalog"));
+
+    createPartitionedTable(spark, tableName, "years(ts)");
+
+    String date = "2017-11-22";
+    String query =
+        sqlFormat(
+            "SELECT * FROM %s WHERE system.years(ts) = 
system.years(date('%s')) ORDER BY id",

Review Comment:
   I think the problem this is trying to solve is that you probably get 
unexpected results when the expression is something like `system.years(ts) = 
2023`. I think this is okay and a good thing to support in general. The problem 
is that it still isn't obvious that the expression is misleading.
   
   I think the right way to fix this is to allow pushing down other functions 
that are compatible and have the expected behavior, like Spark's built-in 
`year` method. That way, rather than using `system.years(ts) = 2023`, the 
caller could use the more-familiar `year(ts) = 2023` and it would work.
   
   Is it possible to push down the built-in `year` method? @RussellSpitzer or 
@huaxingao, do you know?
   
   We'd need to find out what gets passed as its canonical name and whether 
Spark will push it down.
   
   I think we would also want to do the same thing for `month` (when combined 
with `year`?), `to_date`, and other conversions including `cast` if possible.



-- 
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]

Reply via email to