[GitHub] [flink] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-11-04 Thread GitBox
bowenli86 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_r342240835
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV120.java
 ##
 @@ -168,4 +175,44 @@ public CatalogColumnStatisticsDataDate 
toFlinkDateColStats(ColumnStatisticsData
throw new CatalogException("Failed to create Flink 
statistics for date column", e);
}
}
+
+   @Override
+   public Set listBuiltInFunctions() {
+   try {
+   Method method = 
FunctionRegistry.class.getMethod("getFunctionNames");
+   // getFunctionNames is a static method
+   Set names = (Set) method.invoke(null);
+
+   return names.stream()
+   .filter(n -> 
isBuiltInFunctionInfo(getFunctionInfo(n)))
+   .collect(Collectors.toSet());
+   } catch (Exception ex) {
+   throw new CatalogException("Failed to invoke 
FunctionRegistry.getFunctionNames()", ex);
+   }
+   }
+
+   @Override
+   public Optional getBuiltInFunctionInfo(String name) {
+   FunctionInfo functionInfo = getFunctionInfo(name);
+
+   return isBuiltInFunctionInfo(functionInfo) ? 
Optional.of(functionInfo) : Optional.empty();
 
 Review comment:
   good catch. I fixed that part, and added UT. Pls take another look


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-11-01 Thread GitBox
bowenli86 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_r341781944
 
 

 ##
 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 haven't seen a requirement to list/get non built-in functions yet, thus 
probably better not to do it now. Limitations will be mentioned when I write 
docs for HiveModule.


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-11-01 Thread GitBox
bowenli86 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_r341686746
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV120.java
 ##
 @@ -168,4 +174,47 @@ public CatalogColumnStatisticsDataDate 
toFlinkDateColStats(ColumnStatisticsData
throw new CatalogException("Failed to create Flink 
statistics for date column", e);
}
}
+
+   @Override
+   public Set listBuiltInFunctions() {
+   try {
+   Method method = 
FunctionRegistry.class.getMethod("getFunctionNames");
+   // makeSpecFromName is a static method
+   Set names = (Set) method.invoke(null);
+
+   return names.stream()
+   .filter(n -> getFunctionInfo(n).isBuiltIn())
 
 Review comment:
   good catch. Seems I didn't rebuilt src but just reran tests


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-11-01 Thread GitBox
bowenli86 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_r341667362
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV110.java
 ##
 @@ -294,4 +296,19 @@ public boolean isDateStats(ColumnStatisticsData 
colStatsData) {
public CatalogColumnStatisticsDataDate 
toFlinkDateColStats(ColumnStatisticsData hiveDateColStats) {
throw new UnsupportedOperationException("DATE column stats are 
not supported until Hive 1.2.0");
}
+
+   @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");
 
 Review comment:
   no, persistent function is also native


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-11-01 Thread GitBox
bowenli86 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_r341667362
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/client/HiveShimV110.java
 ##
 @@ -294,4 +296,19 @@ public boolean isDateStats(ColumnStatisticsData 
colStatsData) {
public CatalogColumnStatisticsDataDate 
toFlinkDateColStats(ColumnStatisticsData hiveDateColStats) {
throw new UnsupportedOperationException("DATE column stats are 
not supported until Hive 1.2.0");
}
+
+   @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");
 
 Review comment:
   unfortunately no, persistent function is also native


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-30 Thread GitBox
bowenli86 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_r340846801
 
 

 ##
 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:
   my bad. that's a mistake.


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-30 Thread GitBox
bowenli86 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_r340846801
 
 

 ##
 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:
   my bad. that's a mistake. Changing to use `HiveShimLoader.getHiveVersion()`


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-30 Thread GitBox
bowenli86 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_r340847504
 
 

 ##
 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.
   
   I switched it to a lightweight test
   
   > One thing though, we probably don't want a hardcoded Hive version. Rather, 
we should use the version in the build.
   
   Agree. Changed to use HiveShimLoader.getHiveVersion()
   
   


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-30 Thread GitBox
bowenli86 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_r340846801
 
 

 ##
 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:
   my bad. that shouldn't be in the test. Changing to use 
`HiveShimLoader.getHiveVersion()`


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-30 Thread GitBox
bowenli86 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_r340749076
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/factories/HiveFunctionDefinitionFactory.java
 ##
 @@ -67,14 +69,26 @@ public HiveFunctionDefinitionFactory(HiveConf hiveConf) {
this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
}
 
+   public HiveFunctionDefinitionFactory(String hiveVersion) {
 
 Review comment:
   I agree. We should pass HiveShim instance around rather than a Hive version. 
I've added a separate commit to tackle this issue thru our stack


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-29 Thread GitBox
bowenli86 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_r340315608
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/factories/HiveFunctionDefinitionFactory.java
 ##
 @@ -67,14 +69,26 @@ public HiveFunctionDefinitionFactory(HiveConf hiveConf) {
this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
}
 
+   public HiveFunctionDefinitionFactory(String hiveVersion) {
 
 Review comment:
   can you elaborate? do you mean passing in a HiveShim?


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-29 Thread GitBox
bowenli86 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_r340315608
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/factories/HiveFunctionDefinitionFactory.java
 ##
 @@ -67,14 +69,26 @@ public HiveFunctionDefinitionFactory(HiveConf hiveConf) {
this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
}
 
+   public HiveFunctionDefinitionFactory(String hiveVersion) {
 
 Review comment:
   do you mean passing in a HiveShim? can you elaborate?


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-29 Thread GitBox
bowenli86 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_r340318129
 
 

 ##
 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:
   I agree it's too heavy


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-29 Thread GitBox
bowenli86 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_r340315950
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/factories/HiveFunctionDefinitionFactory.java
 ##
 @@ -67,14 +69,26 @@ public HiveFunctionDefinitionFactory(HiveConf hiveConf) {
this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
}
 
+   public HiveFunctionDefinitionFactory(String hiveVersion) {
+   checkArgument(!StringUtils.isNullOrWhitespaceOnly(hiveVersion),
+   "Hive version cannot be null or empty string");
+   this.hiveVersion = hiveVersion;
+   this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
+   }
+
@Override
public FunctionDefinition createFunctionDefinition(String name, 
CatalogFunction catalogFunction) {
if 
(Boolean.valueOf(catalogFunction.getProperties().get(CatalogConfig.IS_GENERIC)))
 {
FunctionDefinitionUtil.createFunctionDefinition(name, 
catalogFunction);
}
 
-   String functionClassName = catalogFunction.getClassName();
+   return createFunctionDefinitionFromHiveFunction(name, 
catalogFunction.getClassName());
+   }
 
+   /**
+* Create a FunctionDefinition from a Hive function's class name.
+*/
+   public FunctionDefinition 
createFunctionDefinitionFromHiveFunction(String name, String functionClassName) 
{
 
 Review comment:
   it's used in HiveModule


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] bowenli86 commented on a change in pull request #9988: [FLINK-14418][hive] Create HiveModule to provide Hive built-in functions

2019-10-29 Thread GitBox
bowenli86 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_r340315608
 
 

 ##
 File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/factories/HiveFunctionDefinitionFactory.java
 ##
 @@ -67,14 +69,26 @@ public HiveFunctionDefinitionFactory(HiveConf hiveConf) {
this.hiveShim = HiveShimLoader.loadHiveShim(hiveVersion);
}
 
+   public HiveFunctionDefinitionFactory(String hiveVersion) {
 
 Review comment:
   what do you mean? can you elaborate?


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