This is an automated email from the ASF dual-hosted git repository.

danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git


The following commit(s) were added to refs/heads/master by this push:
     new dd31c9b5d8d [MINOR] NPE fix while adding projection field & added its 
test cases (#10313)
dd31c9b5d8d is described below

commit dd31c9b5d8dc11db43ebce220a1f45c93ea5ca53
Author: Prathit malik <[email protected]>
AuthorDate: Thu Dec 14 09:57:58 2023 +0530

    [MINOR] NPE fix while adding projection field & added its test cases 
(#10313)
---
 .../utils/HoodieRealtimeInputFormatUtils.java      |  2 +-
 .../utils/TestHoodieRealtimeInputFormatUtils.java  | 49 ++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git 
a/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
 
b/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
index b992d568fea..b8308011fd8 100644
--- 
a/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
+++ 
b/hudi-hadoop-mr/src/main/java/org/apache/hudi/hadoop/utils/HoodieRealtimeInputFormatUtils.java
@@ -86,7 +86,7 @@ public class HoodieRealtimeInputFormatUtils extends 
HoodieInputFormatUtils {
 
   public static void addProjectionField(Configuration conf, String[] 
fieldName) {
     if (fieldName.length > 0) {
-      List<String> columnNameList = 
Arrays.stream(conf.get(serdeConstants.LIST_COLUMNS).split(",")).collect(Collectors.toList());
+      List<String> columnNameList = 
Arrays.stream(conf.get(serdeConstants.LIST_COLUMNS, 
"").split(",")).collect(Collectors.toList());
       Arrays.stream(fieldName).forEach(field -> {
         int index = columnNameList.indexOf(field);
         if (index != -1) {
diff --git 
a/hudi-hadoop-mr/src/test/java/org/apache/hudi/hadoop/utils/TestHoodieRealtimeInputFormatUtils.java
 
b/hudi-hadoop-mr/src/test/java/org/apache/hudi/hadoop/utils/TestHoodieRealtimeInputFormatUtils.java
new file mode 100644
index 00000000000..354b710478c
--- /dev/null
+++ 
b/hudi-hadoop-mr/src/test/java/org/apache/hudi/hadoop/utils/TestHoodieRealtimeInputFormatUtils.java
@@ -0,0 +1,49 @@
+/*
+ * 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 org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
+
+import org.apache.hudi.common.testutils.HoodieTestUtils;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+public class TestHoodieRealtimeInputFormatUtils {
+
+  private Configuration hadoopConf;
+
+  @TempDir
+  public java.nio.file.Path basePath;
+
+  @BeforeEach
+  public void setUp() {
+    hadoopConf = HoodieTestUtils.getDefaultHadoopConf();
+    hadoopConf.set("fs.defaultFS", "file:///");
+    hadoopConf.set("fs.file.impl", 
org.apache.hadoop.fs.LocalFileSystem.class.getName());
+  }
+
+  @Test
+  public void testAddProjectionField() {
+    hadoopConf.set(hive_metastoreConstants.META_TABLE_PARTITION_COLUMNS, "");
+    HoodieRealtimeInputFormatUtils.addProjectionField(hadoopConf, 
hadoopConf.get(hive_metastoreConstants.META_TABLE_PARTITION_COLUMNS, 
"").split("/"));
+  }
+}

Reply via email to