[GitHub] [flink] xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions
xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions URL: https://github.com/apache/flink/pull/9988#discussion_r341750761 ## File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV100.java ## @@ -335,4 +338,18 @@ public CatalogColumnStatisticsDataDate toFlinkDateColStats(ColumnStatisticsData throw new CatalogException("Failed to get table schema from deserializer", e); } } + + @Override + public Set listBuiltInFunctions() { + // FunctionInfo doesn't have isBuiltIn() API to tell whether it's a builtin function or not + // prior to Hive 1.2.0 + throw new UnsupportedOperationException("Listing built in functions are not supported until Hive 1.2.0"); + } + + @Override + public Optional getBuiltInFunctionInfo(String name) { + // FunctionInfo doesn't have isBuiltIn() API to tell whether it's a builtin function or not + // prior to Hive 1.2.0 + throw new UnsupportedOperationException("Getting built in functions are not supported until Hive 1.2.0"); + } Review comment: I think we have two options: 1. Document the restriction (with a JIRA to track) 2. Just list all functions which might include non-built-in ones. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions
xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions URL: https://github.com/apache/flink/pull/9988#discussion_r340782496 ## File path: flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/module/hive/HiveModuleITCase.java ## @@ -0,0 +1,150 @@ +/* + * 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.flink.table.module.hive; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.TableEnvironment; +import org.apache.flink.table.api.TableSchema; +import org.apache.flink.table.api.Types; +import org.apache.flink.table.catalog.Catalog; +import org.apache.flink.table.catalog.CatalogTable; +import org.apache.flink.table.catalog.CatalogTableBuilder; +import org.apache.flink.table.catalog.ObjectPath; +import org.apache.flink.table.descriptors.FileSystem; +import org.apache.flink.table.descriptors.FormatDescriptor; +import org.apache.flink.table.descriptors.OldCsv; +import org.apache.flink.table.planner.runtime.utils.BatchTestBase; +import org.apache.flink.test.util.AbstractTestBase; +import org.apache.flink.util.FileUtils; + +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static java.lang.String.format; + +/** + * IT case for {@link HiveModule}. + */ +public class HiveModuleITCase extends AbstractTestBase { + + @Rule + public TemporaryFolder tempFolder = new TemporaryFolder(); + + private String sourceTableName = "csv_source"; + private String sinkTableName = "csv_sink"; + private final String testFunctionName = "reverse"; + + @Test + public void testHiveBuiltinFunction() throws Exception { Review comment: While it's a little unwieldy, I think it's an important test to verify that Hive module can be actually loaded and Hive built-in function can be called. One thing though, we probably don't want a hardcoded Hive version. Rather, we should use the version in the build. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services
[GitHub] [flink] xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions
xuefuz commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions URL: https://github.com/apache/flink/pull/9988#discussion_r340784546 ## File path: flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/table/module/hive/HiveModuleTest.java ## @@ -0,0 +1,60 @@ +/* + * 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.flink.table.module.hive; + +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.functions.FunctionDefinition; +import org.apache.flink.table.functions.ScalarFunction; +import org.apache.flink.table.functions.ScalarFunctionDefinition; +import org.apache.flink.table.functions.hive.HiveSimpleUDF; +import org.apache.flink.table.types.DataType; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Test for {@link HiveModule}. + */ +public class HiveModuleTest { + @Test + public void testNumberOfBuiltinFunctions() { + assertEquals(287, new HiveModule("1.2.0").listFunctions().size()); + assertEquals(287, new HiveModule("2.1.1").listFunctions().size()); + assertEquals(287, new HiveModule("3.1.2").listFunctions().size()); Review comment: I'm curious how we created Hive modules of different Hive versions in a single test because in theory we only have one version of Hive libs in the classpath. It would be a surprise to me if the number of Hive built-in functions are the same for those versions. 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services