rdblue commented on code in PR #7886: URL: https://github.com/apache/iceberg/pull/7886#discussion_r1264763760
########## 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: Yeah, looks like adding support for `org.apache.spark.sql.connector.expressions.Extract` and `org.apache.spark.sql.connector.expressions.Cast` is exactly what we want to do. For now, can you remove the new rule and related codepaths? Let's just get the Iceberg system functions working with static values. You can replace the `system.years(date('%s'))` expression here with `%d` and call the transform directly to create the correct SQL value. That removes the need for the extra rule and we can add it in the next PR. That will unblock getting this PR in. And after this PR could you add support for some of the `Extract` and `Cast` cases? -- 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]
