You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@carbondata.apache.org by ak...@apache.org on 2020/07/29 05:54:55 UTC

[carbondata] branch master updated: [CARBONDATA-3914] Fixed issue on reading data from carbon tabel through hive beeline when no data is present in table.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new e1dac85  [CARBONDATA-3914] Fixed issue on reading data from carbon tabel through hive beeline when no data is present in table.
e1dac85 is described below

commit e1dac85b1596aed12eccd556ccbf5ef9a54f1829
Author: Karan980 <ka...@gmail.com>
AuthorDate: Wed Jul 22 01:15:51 2020 +0530

    [CARBONDATA-3914] Fixed issue on reading data from carbon tabel through hive beeline when no data
    is present in table.
    
    Why is this PR needed?
    Reading data from empty carbontable through hive beeline was giving "Unable read Carbon Schema"
    exception, when no data is present in the carbon table.
    
    What changes were proposed in this PR?
    This PR will help to fix above scenario by returning the empty result when no data is inserted
    in table.
    
    This closes #3857
---
 core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java     | 3 ++-
 .../main/java/org/apache/carbondata/hive/MapredCarbonInputFormat.java  | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
index 9643643..4de25bf 100644
--- a/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
+++ b/core/src/main/java/org/apache/carbondata/core/util/CarbonUtil.java
@@ -24,6 +24,7 @@ import java.io.Closeable;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
@@ -2137,7 +2138,7 @@ public final class CarbonUtil {
     if (fistFilePath == null) {
       // Check if we can infer the schema from the hive metastore.
       LOGGER.error("CarbonData file is not present in the table location");
-      throw new IOException("CarbonData file is not present in the table location");
+      throw new FileNotFoundException("CarbonData file is not present in the table location");
     }
     CarbonHeaderReader carbonHeaderReader = new CarbonHeaderReader(fistFilePath, configuration);
     List<ColumnSchema> columnSchemaList = carbonHeaderReader.readSchema();
diff --git a/integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonInputFormat.java b/integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonInputFormat.java
index e03974e..d99a56b 100644
--- a/integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonInputFormat.java
+++ b/integration/hive/src/main/java/org/apache/carbondata/hive/MapredCarbonInputFormat.java
@@ -17,6 +17,7 @@
 
 package org.apache.carbondata.hive;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
@@ -116,6 +117,8 @@ public class MapredCarbonInputFormat extends CarbonTableInputFormat<ArrayWritabl
     try {
       carbonTable = getCarbonTable(jobContext.getConfiguration(),
           jobContext.getConfiguration().get(hive_metastoreConstants.META_TABLE_LOCATION));
+    } catch (FileNotFoundException e) {
+      return new InputSplit[0];
     } catch (Exception e) {
       throw new IOException("Unable read Carbon Schema: ", e);
     }