You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by fe...@apache.org on 2018/03/29 06:39:38 UTC
zeppelin git commit: ZEPPELIN-3160. Fixed Checkstyle issues in kylin
module
Repository: zeppelin
Updated Branches:
refs/heads/master 930907959 -> d19b35abe
ZEPPELIN-3160. Fixed Checkstyle issues in kylin module
### What is this PR for?
Fixed the Checkstyle issues in the kylin module.
### What type of PR is it?
Improvement
### Todos
* [ ] - Task
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-3160
### How should this be tested?
* CI pass
### Screenshots (if appropriate)
### Questions:
* Does the licenses files need update? no
* Is there breaking changes for older versions? no
* Does this needs documentation? no
Author: Jan Hentschel <ja...@ultratendency.com>
Closes #2895 from HorizonNet/ZEPPELIN-3160 and squashes the following commits:
d01830b [Jan Hentschel] ZEPPELIN-3160. Reverted package-lock.json
455c54d [Jan Hentschel] ZEPPELIN-3160. Fixed Checkstyle issues in kylin module
Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/d19b35ab
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/d19b35ab
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/d19b35ab
Branch: refs/heads/master
Commit: d19b35abe256513a07ebae1e63cc1e17b8091dd3
Parents: 9309079
Author: Jan Hentschel <ja...@ultratendency.com>
Authored: Tue Mar 27 12:22:44 2018 +0200
Committer: Felix Cheung <fe...@apache.org>
Committed: Wed Mar 28 23:39:33 2018 -0700
----------------------------------------------------------------------
kylin/pom.xml | 10 +-
.../zeppelin/kylin/KylinErrorResponse.java | 3 +-
.../apache/zeppelin/kylin/KylinInterpreter.java | 10 +-
.../zeppelin/kylin/KylinInterpreterTest.java | 160 ++++++++++---------
4 files changed, 95 insertions(+), 88 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d19b35ab/kylin/pom.xml
----------------------------------------------------------------------
diff --git a/kylin/pom.xml b/kylin/pom.xml
index 6d78fdf..b70bfb2 100644
--- a/kylin/pom.xml
+++ b/kylin/pom.xml
@@ -73,7 +73,13 @@
<plugin>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
</plugins>
</build>
-
-</project>
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d19b35ab/kylin/src/main/java/org/apache/zeppelin/kylin/KylinErrorResponse.java
----------------------------------------------------------------------
diff --git a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinErrorResponse.java b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinErrorResponse.java
index 00439e8..04d0479 100644
--- a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinErrorResponse.java
+++ b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinErrorResponse.java
@@ -34,7 +34,7 @@ class KylinErrorResponse implements JsonSerializable {
private Object data;
private String msg;
- public KylinErrorResponse(String stacktrace, String exception, String url,
+ KylinErrorResponse(String stacktrace, String exception, String url,
String code, Object data, String msg) {
this.stacktrace = stacktrace;
this.exception = exception;
@@ -59,5 +59,4 @@ class KylinErrorResponse implements JsonSerializable {
return null;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d19b35ab/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
----------------------------------------------------------------------
diff --git a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
index c7cd689..444f5cb 100755
--- a/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
+++ b/kylin/src/main/java/org/apache/zeppelin/kylin/KylinInterpreter.java
@@ -24,10 +24,6 @@ import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.zeppelin.interpreter.Interpreter;
-import org.apache.zeppelin.interpreter.InterpreterContext;
-import org.apache.zeppelin.interpreter.InterpreterResult;
-import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,6 +33,11 @@ import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.zeppelin.interpreter.Interpreter;
+import org.apache.zeppelin.interpreter.InterpreterContext;
+import org.apache.zeppelin.interpreter.InterpreterResult;
+import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion;
+
/**
* Kylin interpreter for Zeppelin. (http://kylin.apache.org)
*/
@@ -233,5 +234,4 @@ public class KylinInterpreter extends Interpreter {
}
return res.toString();
}
-
}
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/d19b35ab/kylin/src/test/java/org/apache/zeppelin/kylin/KylinInterpreterTest.java
----------------------------------------------------------------------
diff --git a/kylin/src/test/java/org/apache/zeppelin/kylin/KylinInterpreterTest.java b/kylin/src/test/java/org/apache/zeppelin/kylin/KylinInterpreterTest.java
index 35f0f3c..66b6f9a 100755
--- a/kylin/src/test/java/org/apache/zeppelin/kylin/KylinInterpreterTest.java
+++ b/kylin/src/test/java/org/apache/zeppelin/kylin/KylinInterpreterTest.java
@@ -19,13 +19,6 @@ package org.apache.zeppelin.kylin;
import static org.junit.Assert.assertEquals;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Locale;
-import java.util.Properties;
-
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
@@ -33,23 +26,31 @@ import org.apache.http.ProtocolVersion;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.message.AbstractHttpMessage;
-import org.apache.zeppelin.interpreter.InterpreterResult;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Locale;
+import java.util.Properties;
+
+import org.apache.zeppelin.interpreter.InterpreterResult;
+
public class KylinInterpreterTest {
- static final Properties kylinProperties = new Properties();
+ static final Properties KYLIN_PROPERTIES = new Properties();
@BeforeClass
public static void setUpClass() {
- kylinProperties.put("kylin.api.url", "http://localhost:7070/kylin/api/query");
- kylinProperties.put("kylin.api.user", "ADMIN");
- kylinProperties.put("kylin.api.password", "KYLIN");
- kylinProperties.put("kylin.query.project", "default");
- kylinProperties.put("kylin.query.offset", "0");
- kylinProperties.put("kylin.query.limit", "5000");
- kylinProperties.put("kylin.query.ispartial", "true");
+ KYLIN_PROPERTIES.put("kylin.api.url", "http://localhost:7070/kylin/api/query");
+ KYLIN_PROPERTIES.put("kylin.api.user", "ADMIN");
+ KYLIN_PROPERTIES.put("kylin.api.password", "KYLIN");
+ KYLIN_PROPERTIES.put("kylin.query.project", "default");
+ KYLIN_PROPERTIES.put("kylin.query.offset", "0");
+ KYLIN_PROPERTIES.put("kylin.query.limit", "5000");
+ KYLIN_PROPERTIES.put("kylin.query.ispartial", "true");
}
@Test
@@ -58,47 +59,57 @@ public class KylinInterpreterTest {
InterpreterResult result = t.interpret(
"select a.date,sum(b.measure) as measure from kylin_fact_table a " +
"inner join kylin_lookup_table b on a.date=b.date group by a.date", null);
- assertEquals("default", t.getProject("select a.date,sum(b.measure) as measure " +
- "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date group by a.date"));
- assertEquals(InterpreterResult.Type.TABLE,result.message().get(0).getType());
+ assertEquals("default", t.getProject("select a.date,sum(b.measure) as measure "
+ + "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date "
+ + "group by a.date"));
+ assertEquals(InterpreterResult.Type.TABLE, result.message().get(0).getType());
}
@Test
public void testWithProject() {
KylinInterpreter t = new MockKylinInterpreter(getDefaultProperties());
- assertEquals("project2", t.getProject("(project2)\n select a.date,sum(b.measure) as measure " +
- "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date group by a.date"));
- assertEquals("", t.getProject("()\n select a.date,sum(b.measure) as measure " +
- "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date group by a.date"));
- assertEquals("\n select a.date,sum(b.measure) as measure from kylin_fact_table a inner join " +
- "kylin_lookup_table b on a.date=b.date group by a.date", t.getSQL("(project2)\n select a.date," +
- "sum(b.measure) as measure from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date " +
- "group by a.date"));
- assertEquals("\n select a.date,sum(b.measure) as measure from kylin_fact_table a inner join kylin_lookup_table b " +
- "on a.date=b.date group by a.date", t.getSQL("()\n select a.date,sum(b.measure) as measure " +
- "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date group by a.date"));
+ assertEquals("project2", t.getProject("(project2)\n select a.date,sum(b.measure) "
+ + "as measure from kylin_fact_table a inner join kylin_lookup_table b on "
+ + "a.date=b.date group by a.date"));
+ assertEquals("", t.getProject("()\n select a.date,sum(b.measure) as measure "
+ + "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date "
+ + "group by a.date"));
+ assertEquals("\n select a.date,sum(b.measure) as measure from kylin_fact_table a "
+ + "inner join kylin_lookup_table b on a.date=b.date group by a.date",
+ t.getSQL("(project2)\n select a.date,sum(b.measure) as measure "
+ + "from kylin_fact_table a inner join kylin_lookup_table b on a.date=b.date "
+ + "group by a.date"));
+ assertEquals("\n select a.date,sum(b.measure) as measure from kylin_fact_table a "
+ + "inner join kylin_lookup_table b on a.date=b.date group by a.date",
+ t.getSQL("()\n select a.date,sum(b.measure) as measure from kylin_fact_table a "
+ + "inner join kylin_lookup_table b on a.date=b.date group by a.date"));
}
@Test
public void testParseResult() {
- String msg = "{\"columnMetas\":[{\"isNullable\":1,\"displaySize\":256,\"label\":\"COUNTRY\",\"name\":\"COUNTRY\","
- + "\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\",\"precision\":256,"
- + "\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\",\"writable\":false,\"readOnly\":true,"
- + "\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":false,"
- + "\"currency\":false,\"signed\":true},{\"isNullable\":1,\"displaySize\":256,\"label\":\"CURRENCY\","
- + "\"name\":\"CURRENCY\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\","
- + "\"precision\":256,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\",\"writable\":false,"
- + "\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,"
- + "\"searchable\":false,\"currency\":false,\"signed\":true},{\"isNullable\":0,\"displaySize\":19,"
- + "\"label\":\"COUNT__\",\"name\":\"COUNT__\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,"
- + "\"tableName\":\"SALES_TABLE\",\"precision\":19,\"scale\":0,\"columnType\":-5,\"columnTypeName\":"
- + "\"BIGINT\",\"writable\":false,\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,"
- + "\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true}],\"results\":"
- + "[[\"AMERICA\",\"USD\",null],[null,\"RMB\",0],[\"KOR\",null,100],[\"\\\"abc\\\"\",\"a,b,c\",-1]],"
- + "\"cube\":\"Sample_Cube\",\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,"
- + "\"duration\":134,\"totalScanCount\":1,\"hitExceptionCache\":false,\"storageCacheUsed\":false,"
+ String msg = "{\"columnMetas\":[{\"isNullable\":1,\"displaySize\":256,\"label\":\"COUNTRY\","
+ + "\"name\":\"COUNTRY\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,"
+ + "\"tableName\":\"SALES_TABLE\",\"precision\":256,\"scale\":0,\"columnType\":12,"
+ + "\"columnTypeName\":\"VARCHAR\",\"writable\":false,\"readOnly\":true,"
+ + "\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,"
+ + "\"searchable\":false,\"currency\":false,\"signed\":true},{\"isNullable\":1,"
+ + "\"displaySize\":256,\"label\":\"CURRENCY\",\"name\":\"CURRENCY\","
+ + "\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\","
+ + "\"precision\":256,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\","
+ + "\"writable\":false,\"readOnly\":true,\"definitelyWritable\":false,"
+ + "\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":false,"
+ + "\"currency\":false,\"signed\":true},{\"isNullable\":0,\"displaySize\":19,"
+ + "\"label\":\"COUNT__\",\"name\":\"COUNT__\",\"schemaName\":\"DEFAULT\","
+ + "\"catelogName\":null,\"tableName\":\"SALES_TABLE\",\"precision\":19,\"scale\":0,"
+ + "\"columnType\":-5,\"columnTypeName\":\"BIGINT\",\"writable\":false,"
+ + "\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,"
+ + "\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true}],"
+ + "\"results\":[[\"AMERICA\",\"USD\",null],[null,\"RMB\",0],[\"KOR\",null,100],"
+ + "[\"\\\"abc\\\"\",\"a,b,c\",-1]],\"cube\":\"Sample_Cube\",\"affectedRowCount\":0,"
+ + "\"isException\":false,\"exceptionMessage\":null,\"duration\":134,"
+ + "\"totalScanCount\":1,\"hitExceptionCache\":false,\"storageCacheUsed\":false,"
+ "\"partial\":false}";
- String expected="%table COUNTRY \tCURRENCY \tCOUNT__ \t \n" +
+ String expected = "%table COUNTRY \tCURRENCY \tCOUNT__ \t \n" +
"AMERICA \tUSD \tnull \t \n" +
"null \tRMB \t0 \t \n" +
"KOR \tnull \t100 \t \n" +
@@ -110,23 +121,28 @@ public class KylinInterpreterTest {
@Test
public void testParseEmptyResult() {
- String msg = "{\"columnMetas\":[{\"isNullable\":1,\"displaySize\":256,\"label\":\"COUNTRY\",\"name\":\"COUNTRY\","
- + "\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\",\"precision\":256,"
- + "\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\",\"writable\":false,\"readOnly\":true,"
- + "\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":false,"
- + "\"currency\":false,\"signed\":true},{\"isNullable\":1,\"displaySize\":256,\"label\":\"CURRENCY\","
- + "\"name\":\"CURRENCY\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\","
- + "\"precision\":256,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\",\"writable\":false,"
- + "\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,"
- + "\"searchable\":false,\"currency\":false,\"signed\":true},{\"isNullable\":0,\"displaySize\":19,"
- + "\"label\":\"COUNT__\",\"name\":\"COUNT__\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,"
- + "\"tableName\":\"SALES_TABLE\",\"precision\":19,\"scale\":0,\"columnType\":-5,\"columnTypeName\":"
- + "\"BIGINT\",\"writable\":false,\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,"
- + "\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true}],\"results\":"
- + "[]," + "\"cube\":\"Sample_Cube\",\"affectedRowCount\":0,\"isException\":false,\"exceptionMessage\":null,"
- + "\"duration\":134,\"totalScanCount\":1,\"hitExceptionCache\":false,\"storageCacheUsed\":false,"
- + "\"partial\":false}";
- String expected="%table COUNTRY \tCURRENCY \tCOUNT__ \t \n";
+ String msg = "{\"columnMetas\":[{\"isNullable\":1,\"displaySize\":256,\"label\":\"COUNTRY\","
+ + "\"name\":\"COUNTRY\",\"schemaName\":\"DEFAULT\",\"catelogName\":null,"
+ + "\"tableName\":\"SALES_TABLE\",\"precision\":256,\"scale\":0,\"columnType\":12,"
+ + "\"columnTypeName\":\"VARCHAR\",\"writable\":false,\"readOnly\":true,"
+ + "\"definitelyWritable\":false,\"autoIncrement\":false,\"caseSensitive\":true,"
+ + "\"searchable\":false,\"currency\":false,\"signed\":true},{\"isNullable\":1,"
+ + "\"displaySize\":256,\"label\":\"CURRENCY\",\"name\":\"CURRENCY\","
+ + "\"schemaName\":\"DEFAULT\",\"catelogName\":null,\"tableName\":\"SALES_TABLE\","
+ + "\"precision\":256,\"scale\":0,\"columnType\":12,\"columnTypeName\":\"VARCHAR\","
+ + "\"writable\":false,\"readOnly\":true,\"definitelyWritable\":false,"
+ + "\"autoIncrement\":false,\"caseSensitive\":true,\"searchable\":false,"
+ + "\"currency\":false,\"signed\":true},{\"isNullable\":0,\"displaySize\":19,"
+ + "\"label\":\"COUNT__\",\"name\":\"COUNT__\",\"schemaName\":\"DEFAULT\","
+ + "\"catelogName\":null,\"tableName\":\"SALES_TABLE\",\"precision\":19,\"scale\":0,"
+ + "\"columnType\":-5,\"columnTypeName\":\"BIGINT\",\"writable\":false,"
+ + "\"readOnly\":true,\"definitelyWritable\":false,\"autoIncrement\":false,"
+ + "\"caseSensitive\":true,\"searchable\":false,\"currency\":false,\"signed\":true}],"
+ + "\"results\":[]," + "\"cube\":\"Sample_Cube\",\"affectedRowCount\":0,"
+ + "\"isException\":false,\"exceptionMessage\":null,\"duration\":134,"
+ + "\"totalScanCount\":1,\"hitExceptionCache\":false,\"storageCacheUsed\":false,"
+ + "\"partial\":false}";
+ String expected = "%table COUNTRY \tCURRENCY \tCOUNT__ \t \n";
KylinInterpreter t = new MockKylinInterpreter(getDefaultProperties());
String actual = t.formatResult(msg);
Assert.assertEquals(expected, actual);
@@ -146,8 +162,7 @@ public class KylinInterpreterTest {
}
class MockKylinInterpreter extends KylinInterpreter {
-
- public MockKylinInterpreter(Properties property) {
+ MockKylinInterpreter(Properties property) {
super(property);
}
@@ -156,7 +171,6 @@ class MockKylinInterpreter extends KylinInterpreter {
MockHttpClient client = new MockHttpClient();
return client.execute(new HttpPost());
}
-
}
class MockHttpClient{
@@ -166,7 +180,6 @@ class MockHttpClient{
}
class MockHttpResponse extends AbstractHttpMessage implements HttpResponse{
-
@Override
public StatusLine getStatusLine() {
return new MockStatusLine();
@@ -174,27 +187,22 @@ class MockHttpResponse extends AbstractHttpMessage implements HttpResponse{
@Override
public void setStatusLine(StatusLine statusLine) {
-
}
@Override
public void setStatusLine(ProtocolVersion protocolVersion, int i) {
-
}
@Override
public void setStatusLine(ProtocolVersion protocolVersion, int i, String s) {
-
}
@Override
public void setStatusCode(int i) throws IllegalStateException {
-
}
@Override
public void setReasonPhrase(String s) throws IllegalStateException {
-
}
@Override
@@ -204,7 +212,6 @@ class MockHttpResponse extends AbstractHttpMessage implements HttpResponse{
@Override
public void setEntity(HttpEntity httpEntity) {
-
}
@Override
@@ -214,7 +221,6 @@ class MockHttpResponse extends AbstractHttpMessage implements HttpResponse{
@Override
public void setLocale(Locale locale) {
-
}
@Override
@@ -224,7 +230,6 @@ class MockHttpResponse extends AbstractHttpMessage implements HttpResponse{
}
class MockStatusLine implements StatusLine{
-
@Override
public ProtocolVersion getProtocolVersion() {
return null;
@@ -242,7 +247,6 @@ class MockStatusLine implements StatusLine{
}
class MockEntity implements HttpEntity{
-
@Override
public boolean isRepeatable() {
return false;
@@ -278,7 +282,6 @@ class MockEntity implements HttpEntity{
@Override
public void writeTo(OutputStream outputStream) throws IOException {
-
}
@Override
@@ -288,6 +291,5 @@ class MockEntity implements HttpEntity{
@Override
public void consumeContent() throws IOException {
-
}
}