Repository: zeppelin
Updated Branches:
  refs/heads/branch-0.8 df06f4542 -> e4a89ba38


ZEPPELIN-3115 Fix bigquery interpreter to remove TAB at end-of-line

Fix bigquery interpreter layout.
The current layout is broken due to a tab character at end-of-line.

Bug Fix

https://issues.apache.org/jira/browse/ZEPPELIN-3115

* Run bigquery interpreter and check the result (Please see below screenshots).

Before (from JIRA issues):
![before](https://issues.apache.org/jira/secure/attachment/12903316/Screen%20Shot%202017-12-21%20at%204.58.58%20PM.png)

After:
![after](https://raw.githubusercontent.com/iijima-satoshi/okhttp/master/fixed_bigquery_layout.png)

* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No

Author: iijima_satoshi <iijima_sato...@cyberagent.co.jp>

Closes #2912 from iijima-satoshi/fix-bigquery-layout and squashes the following 
commits:

f193f6a [iijima_satoshi] ZEPPELIN-3115 Add test for bigquery interpreter output
dd2a198 [iijima_satoshi] ZEPPELIN-3115 BigQuery interpreter does not render the 
output of a sql query (only shows column names)

(cherry picked from commit 36a5a917371a47eb257e8cfdc44930c0eb65560e)
Signed-off-by: Jeff Zhang <zjf...@apache.org>


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

Branch: refs/heads/branch-0.8
Commit: e4a89ba38733569586cde1552ecb32908d6564ec
Parents: df06f45
Author: iijima_satoshi <iijima_sato...@cyberagent.co.jp>
Authored: Sat Apr 7 05:32:52 2018 +0900
Committer: Jeff Zhang <zjf...@apache.org>
Committed: Thu May 10 17:44:01 2018 +0800

----------------------------------------------------------------------
 .../zeppelin/bigquery/BigQueryInterpreter.java     | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/e4a89ba3/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
----------------------------------------------------------------------
diff --git 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
index 4aff742..a176899 100644
--- 
a/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
+++ 
b/bigquery/src/main/java/org/apache/zeppelin/bigquery/BigQueryInterpreter.java
@@ -24,7 +24,7 @@ import com.google.api.client.http.javanet.NetHttpTransport;
 import com.google.api.client.json.JsonFactory;
 import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
 import com.google.api.client.json.jackson2.JacksonFactory;
-
+import com.google.api.client.util.Joiner;
 import com.google.api.services.bigquery.Bigquery;
 import com.google.api.services.bigquery.BigqueryScopes;
 import com.google.api.client.json.GenericJson;
@@ -166,19 +166,20 @@ public class BigQueryInterpreter extends Interpreter {
 
   //Function that generates and returns the schema and the rows as string
   public static String printRows(final GetQueryResultsResponse response) {
-    StringBuilder msg = null;
-    msg = new StringBuilder();
+    StringBuilder msg = new StringBuilder();
     try {
+      List<String> schemNames = new ArrayList<String>();
       for (TableFieldSchema schem: response.getSchema().getFields()) {
-        msg.append(schem.getName());
-        msg.append(TAB);
-      }      
+        schemNames.add(schem.getName());
+      }
+      msg.append(Joiner.on(TAB).join(schemNames));
       msg.append(NEWLINE);
       for (TableRow row : response.getRows()) {
+        List<String> fieldValues = new ArrayList<String>();
         for (TableCell field : row.getF()) {
-          msg.append(field.getV().toString());
-          msg.append(TAB);
+          fieldValues.add(field.getV().toString());
         }
+        msg.append(Joiner.on(TAB).join(fieldValues));
         msg.append(NEWLINE);
       }
       return msg.toString();

Reply via email to