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


##########
spark/v3.4/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestSystemFunctionPushDownDQL.java:
##########
@@ -0,0 +1,260 @@
+/*
+ * 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"));

Review Comment:
   system function can not be resolved with `spark_catalog`. Got the follows 
error. Will address it in a follow-up.
   ```scala
   scala> spark.sql("select spark_catalog.system.years(cast('2017-11-22' as 
timestamp))")
   org.apache.spark.sql.AnalysisException: [SCHEMA_NOT_FOUND] The schema 
`system` cannot be found. Verify the spelling and correctness of the schema and 
catalog.
   If you did not qualify the name with a catalog, verify the current_schema() 
output, or qualify the name with the correct catalog.
   To tolerate the error on drop use DROP SCHEMA IF EXISTS.; line 1 pos 7
     at 
org.apache.spark.sql.catalyst.catalog.ExternalCatalog.requireDbExists(ExternalCatalog.scala:42)
     at 
org.apache.spark.sql.catalyst.catalog.ExternalCatalog.requireDbExists$(ExternalCatalog.scala:40)
     at 
org.apache.spark.sql.hive.HiveExternalCatalog.requireDbExists(HiveExternalCatalog.scala:56)
     at 
org.apache.spark.sql.hive.HiveExternalCatalog.$anonfun$functionExists$1(HiveExternalCatalog.scala:1352)
     at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
   ```



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