You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/04/13 10:37:21 UTC
[15/22] kylin git commit: KYLIN-2541 fix sql missing in logs for
beeline
KYLIN-2541 fix sql missing in logs for beeline
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/bd3b8440
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/bd3b8440
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/bd3b8440
Branch: refs/heads/master-hbase0.98
Commit: bd3b84402a8f75f02d7f5427d3261ee7c880a5d0
Parents: 9532bf2
Author: lidongsjtu <li...@apache.org>
Authored: Tue Apr 11 12:45:48 2017 +0800
Committer: lidongsjtu <li...@apache.org>
Committed: Tue Apr 11 12:45:52 2017 +0800
----------------------------------------------------------------------
.../apache/kylin/common/util/HiveCmdBuilder.java | 16 ++++++++++++----
.../kylin/common/util/HiveCmdBuilderTest.java | 1 +
2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd3b8440/core-common/src/main/java/org/apache/kylin/common/util/HiveCmdBuilder.java
----------------------------------------------------------------------
diff --git a/core-common/src/main/java/org/apache/kylin/common/util/HiveCmdBuilder.java b/core-common/src/main/java/org/apache/kylin/common/util/HiveCmdBuilder.java
index 5942ba9..855ee48 100644
--- a/core-common/src/main/java/org/apache/kylin/common/util/HiveCmdBuilder.java
+++ b/core-common/src/main/java/org/apache/kylin/common/util/HiveCmdBuilder.java
@@ -62,8 +62,9 @@ public class HiveCmdBuilder {
break;
case BEELINE:
BufferedWriter bw = null;
+ File tmpHql = null;
try {
- File tmpHql = File.createTempFile("beeline_", ".hql");
+ tmpHql = File.createTempFile("beeline_", ".hql");
bw = new BufferedWriter(new FileWriter(tmpHql));
for (String statement : statements) {
bw.write(statement);
@@ -77,13 +78,20 @@ public class HiveCmdBuilder {
buf.append(tmpHql.getAbsolutePath());
buf.append(";exit $ret_code");
- if (logger.isDebugEnabled()) {
- logger.debug("The SQL to execute in beeline: \n" + FileUtils.readFileToString(tmpHql, Charset.defaultCharset()));
- }
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
IOUtils.closeQuietly(bw);
+
+ if (tmpHql != null && logger.isDebugEnabled()) {
+ String hql = null;
+ try {
+ hql = FileUtils.readFileToString(tmpHql, Charset.defaultCharset());
+ } catch (IOException e) {
+ // ignore
+ }
+ logger.debug("The SQL to execute in beeline: \n" + hql);
+ }
}
break;
default:
http://git-wip-us.apache.org/repos/asf/kylin/blob/bd3b8440/core-common/src/test/java/org/apache/kylin/common/util/HiveCmdBuilderTest.java
----------------------------------------------------------------------
diff --git a/core-common/src/test/java/org/apache/kylin/common/util/HiveCmdBuilderTest.java b/core-common/src/test/java/org/apache/kylin/common/util/HiveCmdBuilderTest.java
index 56a64c8..3bc34b4 100644
--- a/core-common/src/test/java/org/apache/kylin/common/util/HiveCmdBuilderTest.java
+++ b/core-common/src/test/java/org/apache/kylin/common/util/HiveCmdBuilderTest.java
@@ -34,6 +34,7 @@ public class HiveCmdBuilderTest {
@Before
public void setup() {
+ System.setProperty("log4j.configuration", "file:../build/conf/kylin-tools-log4j.properties");
System.setProperty("KYLIN_CONF", LocalFileMetadataTestCase.LOCALMETA_TEST_DATA);
}