You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by jc...@apache.org on 2017/10/16 17:55:17 UTC

hive git commit: HIVE-16677 : CTAS with no data fails in Druid (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan) (addendum)

Repository: hive
Updated Branches:
  refs/heads/master 0bf80f3a0 -> 63ff7e2bd


HIVE-16677 : CTAS with no data fails in Druid (Jesus Camacho Rodriguez, reviewed by Ashutosh Chauhan) (addendum)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/63ff7e2b
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/63ff7e2b
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/63ff7e2b

Branch: refs/heads/master
Commit: 63ff7e2bd3630bf51023abfcce4debefaa25a4ea
Parents: 0bf80f3
Author: Jesus Camacho Rodriguez <jc...@apache.org>
Authored: Mon Oct 16 09:53:58 2017 -0700
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Mon Oct 16 09:54:46 2017 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hive/druid/DruidStorageHandler.java     | 1 +
 .../org/apache/hadoop/hive/druid/io/DruidOutputFormat.java    | 7 ++++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/63ff7e2b/druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandler.java
----------------------------------------------------------------------
diff --git a/druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandler.java b/druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandler.java
index cc409ab..8117633 100644
--- a/druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandler.java
+++ b/druid-handler/src/java/org/apache/hadoop/hive/druid/DruidStorageHandler.java
@@ -544,6 +544,7 @@ public class DruidStorageHandler extends DefaultHiveMetaHook implements HiveStor
 
   @Override
   public void configureOutputJobProperties(TableDesc tableDesc, Map<String, String> jobProperties) {
+    jobProperties.put(Constants.DRUID_DATA_SOURCE, tableDesc.getTableName());
     jobProperties.put(Constants.DRUID_SEGMENT_VERSION, new DateTime().toString());
     jobProperties.put(Constants.DRUID_JOB_WORKING_DIRECTORY, getStagingWorkingDir().toString());
     // DruidOutputFormat will write segments in an intermediate directory

http://git-wip-us.apache.org/repos/asf/hive/blob/63ff7e2b/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
----------------------------------------------------------------------
diff --git a/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java b/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
index da7642c..664e02f 100644
--- a/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
+++ b/druid-handler/src/java/org/apache/hadoop/hive/druid/io/DruidOutputFormat.java
@@ -92,7 +92,12 @@ public class DruidOutputFormat<K, V> implements HiveOutputFormat<K, DruidWritabl
             tableProperties.getProperty(Constants.DRUID_SEGMENT_GRANULARITY) != null ?
                     tableProperties.getProperty(Constants.DRUID_SEGMENT_GRANULARITY) :
                     HiveConf.getVar(jc, HiveConf.ConfVars.HIVE_DRUID_INDEXING_GRANULARITY);
-    final String dataSource = tableProperties.getProperty(Constants.DRUID_DATA_SOURCE);
+    // If datasource is in the table properties, it is an INSERT/INSERT OVERWRITE as the datasource
+    // name was already persisted. Otherwise, it is a CT/CTAS and we need to get the name from the
+    // job properties that are set by configureOutputJobProperties in the DruidStorageHandler
+    final String dataSource = tableProperties.getProperty(Constants.DRUID_DATA_SOURCE) == null
+        ? jc.get(Constants.DRUID_DATA_SOURCE)
+        : tableProperties.getProperty(Constants.DRUID_DATA_SOURCE);
     final String segmentDirectory = jc.get(Constants.DRUID_SEGMENT_INTERMEDIATE_DIRECTORY);
 
     final GranularitySpec granularitySpec = new UniformGranularitySpec(