flyrain commented on code in PR #14954: URL: https://github.com/apache/iceberg/pull/14954#discussion_r2743889247
########## spark/v4.1/spark-extensions/src/test/java/org/apache/iceberg/spark/extensions/TestRestScalarFunctionCatalog.java: ########## @@ -0,0 +1,127 @@ +/* + * 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.assertj.core.api.Assertions.assertThat; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import java.util.Arrays; +import org.apache.iceberg.CatalogProperties; +import org.apache.iceberg.ParameterizedTestExtension; +import org.apache.iceberg.Parameters; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; +import org.apache.iceberg.spark.SparkCatalogConfig; +import org.apache.spark.sql.connector.catalog.FunctionCatalog; +import org.apache.spark.sql.connector.catalog.Identifier; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestTemplate; +import org.junit.jupiter.api.extension.ExtendWith; + +/** + * End-to-end test for REST-backed scalar SQL UDFs executed via Iceberg Spark extensions. + * + * <p>Stage 1: scalar only. UDTF/table functions will be added in a follow-up (stage 2). + */ +@ExtendWith(ParameterizedTestExtension.class) +public class TestRestScalarFunctionCatalog extends ExtensionsTestBase { + + private static final String FUNCTION_NAMESPACE = "udf_ns"; + + // Catalog-backed (production) REST functions are only supported for the REST catalog type. + @Parameters(name = "catalogName = {0}, implementation = {1}, config = {2}") + protected static Object[][] parameters() { + return new Object[][] { + { + SparkCatalogConfig.REST.catalogName(), + SparkCatalogConfig.REST.implementation(), + ImmutableMap.builder() + .putAll(SparkCatalogConfig.REST.properties()) + .put(CatalogProperties.URI, restCatalog.properties().get(CatalogProperties.URI)) + .build() + } + }; + } + + private static final ObjectMapper MAPPER = new ObjectMapper(); + + private static final String ADD_ONE_SPEC = + "{" + + "\"function-uuid\":\"123\"," + + "\"format-version\":1," + + "\"doc\":\"Add one UDF\"," + + "\"parameter-names\":[{\"name\":\"x\"}]," + + "\"definitions\":[{" + + " \"definition-id\":\"(int)\"," Review Comment: We are trying to remove parens from the definition id, `(int)` -> `int`. We can change it until the UDF spec is finalized. -- 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]
