You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by sh...@apache.org on 2020/03/05 11:21:20 UTC

[kylin] branch 3.0.x updated: KYLIN-4400: use client in config to submit sql in system-cube.sh

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

shaofengshi pushed a commit to branch 3.0.x
in repository https://gitbox.apache.org/repos/asf/kylin.git


The following commit(s) were added to refs/heads/3.0.x by this push:
     new 35bd44b  KYLIN-4400: use client in config to submit sql in system-cube.sh
35bd44b is described below

commit 35bd44bab5d2c184dfd7b8fbc769c6ad20e4e903
Author: Zhou Kang <zh...@xiaomi.com>
AuthorDate: Tue Mar 3 22:17:08 2020 +0800

    KYLIN-4400: use client in config to submit sql in system-cube.sh
---
 build/bin/system-cube.sh | 40 +++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

diff --git a/build/bin/system-cube.sh b/build/bin/system-cube.sh
index 504c1e4..de28e46 100644
--- a/build/bin/system-cube.sh
+++ b/build/bin/system-cube.sh
@@ -88,16 +88,42 @@ then
 	  ]
 	]
 	EOF
-    $KYLIN_HOME/bin/kylin.sh org.apache.kylin.tool.metrics.systemcube.SCCreator \
-    -inputConfig ${SINK_TOOLS_FILE} \
-    -output ${OUTPUT_FORDER}
+  $KYLIN_HOME/bin/kylin.sh org.apache.kylin.tool.metrics.systemcube.SCCreator \
+  -inputConfig ${SINK_TOOLS_FILE} \
+  -output ${OUTPUT_FORDER}
 
-    hive -f ${OUTPUT_FORDER}/create_hive_tables_for_system_cubes.sql
+  hive_client_mode=`bash ${KYLIN_HOME}/bin/get-properties.sh kylin.source.hive.client`
 
-    $KYLIN_HOME/bin/metastore.sh restore ${OUTPUT_FORDER}
+  # Get Database
+  system_database=`bash ${KYLIN_HOME}/bin/get-properties.sh kylin.source.hive.database-for-flat-table | tr [a-z] [A-Z]`
+
+  # 'create database' failed will not exit when donot have permission to create database;
+  sed -i -e 's/CREATE DATABASE /#CREATE DATABASE /g' ${OUTPUT_FORDER}/create_hive_tables_for_system_cubes.sql
+
+  if [ "${hive_client_mode}" == "beeline" ]
+  then
+      beeline_params=`bash ${KYLIN_HOME}/bin/get-properties.sh kylin.source.hive.beeline-params`
+      beeline ${beeline_params} -e "CREATE DATABASE IF NOT EXISTS "$system_database
+
+      hive2_url=`expr match "${beeline_params}" '.*\(hive2:.*:[0-9]\{4,6\}\/\)'`
+      if [ -z ${hive2_url} ]; then
+          hive2_url=`expr match "${beeline_params}" '.*\(hive2:.*:[0-9]\{4,6\}\)'`
+          beeline_params=${beeline_params/${hive2_url}/${hive2_url}/${sample_database}}
+      else
+          beeline_params=${beeline_params/${hive2_url}/${hive2_url}${sample_database}}
+      fi
+
+      beeline ${beeline_params} -f ${OUTPUT_FORDER}/create_hive_tables_for_system_cubes.sql  || { exit 1; }
+  else
+      hive -e "CREATE DATABASE IF NOT EXISTS "$system_database
+      hive --database $sample_database -f ${OUTPUT_FORDER}/create_hive_tables_for_system_cubes.sql  || { exit 1; }
+  fi
+
+  $KYLIN_HOME/bin/metastore.sh restore ${OUTPUT_FORDER}
+
+  #refresh signature
+  $KYLIN_HOME/bin/kylin.sh org.apache.kylin.cube.cli.CubeSignatureRefresher ${SC_NAME_1},${SC_NAME_2},${SC_NAME_3},${SC_NAME_4},${SC_NAME_5}
 
-    #refresh signature
-    $KYLIN_HOME/bin/kylin.sh org.apache.kylin.cube.cli.CubeSignatureRefresher ${SC_NAME_1},${SC_NAME_2},${SC_NAME_3},${SC_NAME_4},${SC_NAME_5}
 elif [ "$1" == "cron" ]
 then
     #add a crontab job