danny0405 commented on code in PR #8911:
URL: https://github.com/apache/hudi/pull/8911#discussion_r1228975860


##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/shims/HiveCompatibleShim.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * 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.hudi.hadoop.utils.shims;
+
+import java.io.IOException;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.mapred.JobConf;
+
+/**
+ * Shim class to resolve Hive version compatibility.
+ */
+public interface HiveCompatibleShim {

Review Comment:
   Can we merge this interface into HiveShim ?



##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HiveCompatibleUtils.java:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.hudi.hadoop.utils;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.function.Function;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.plan.PartitionDesc;
+
+/**
+ * This class is used to assist compatibility with versions smaller than hive 
2.3 (hive 2.x).
+ * There have been some API changes on hive (2.0-2.2) and hive 2.3, mainly the 
data structure
+ * returned in mapwork.getPathToAliases. In 2.3, the key returned was path, 
while in previous
+ * versions, String was returned. What was done here is to convert it 
uniformly to Path so
+ * that existing code can accommodate these changes

Review Comment:
   All the document should end up with `.`.



##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/shims/HudiHiveInputformatShimAbove23.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.hudi.hadoop.utils.shims;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hive.ql.io.HiveInputFormat;
+import org.apache.hadoop.mapred.JobConf;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * When the hive version is greater than or equal to hive version 2.3
+ */
+public class HudiHiveInputformatShimAbove23 implements HiveCompatibleShim {
+
+  public static final Logger LOG = 
LoggerFactory.getLogger(HudiHiveInputformatShimAbove23.class);
+
+  private static HudiHiveInputformatShimAbove23 INSTANCE = new 
HudiHiveInputformatShimAbove23();
+  public static HiveCompatibleShim getInstance() {
+    return INSTANCE;
+  }
+
+  private static Method PUSH_PROJECT_METHOD;
+
+  static {
+    try {
+      PUSH_PROJECT_METHOD = 
HiveInputFormat.class.getDeclaredMethod("pushProjectionsAndFilters", 
JobConf.class,
+          Class.class, Path.class);

Review Comment:
   Do we need reflection for version 2.3+ ?, the compile version of Hudi Hive 
should be always greater than 2.3.



##########
hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/hive/HoodieCombineHiveInputFormat.java:
##########
@@ -87,16 +91,19 @@
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
+import static 
org.apache.hudi.hadoop.utils.HiveCompatibleUtils.convertPartitionDesc;
+import static 
org.apache.hudi.hadoop.utils.HiveCompatibleUtils.convertMapKeyToPath;
+
 /**
- * This is just a copy of the 
org.apache.hadoop.hive.ql.io.CombineHiveInputFormat from Hive 2.x Search for 
**MOD** to
- * see minor modifications to support custom inputformat in 
CombineHiveInputFormat. See
- * https://issues.apache.org/jira/browse/HIVE-9771
+ * This is just a copy of the 
org.apache.hadoop.hive.ql.io.CombineHiveInputFormat from Hive 2.x
+ * Search for **MOD** to see minor modifications to support custom inputformat 
in
+ * CombineHiveInputFormat. See https://issues.apache.org/jira/browse/HIVE-9771
  * <p>
  * <p>
- * CombineHiveInputFormat is a parameterized InputFormat which looks at the 
path name and determine the correct
- * InputFormat for that path name from mapredPlan.pathToPartitionInfo(). It 
can be used to read files with different
- * input format in the same map-reduce job.
- *
+ * CombineHiveInputFormat is a parameterized InputFormat which looks at the 
path name and determine
+ * the correct InputFormat for that path name from 
mapredPlan.pathToPartitionInfo(). It can be used
+ * to read files with different input format in the same map-reduce job.

Review Comment:
   Revert all the unnecessary change to the document.



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

Reply via email to