drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vita...@apache.org
Subject [drill] 05/05: DRILL-6866: Upgrade to SqlLine 1.6.0
Date Thu, 29 Nov 2018 20:27:14 GMT
This is an automated email from the ASF dual-hosted git repository.

vitalii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/drill.git

commit bf2b414ac62cfc515fdd77f2688bb110073d764d
Author: Arina Ielchiieva <arina.yelchiyeva@gmail.com>
AuthorDate: Thu Nov 22 15:27:15 2018 +0000

    DRILL-6866: Upgrade to SqlLine 1.6.0
    
    1. Changed SqlLine version to 1.6.0.
    2. Overridden new getVersion method in DrillSqlLineApplication.
    3. Set maxColumnWidth to 80 to avoid issue described in DRILL-6769.
    4. Changed colorScheme to obsidian.
    5. Output null value for varchar / char / boolean types as null instead of empty string.
    6. Changed access modifier from package default to public for JDBC classes that implement
external interfaces to avoid issues when calling methods from these classes using reflection.
    
    closes #1556
---
 .../apache/drill/exec/client/DrillSqlLineApplication.java | 11 ++++++++---
 exec/java-exec/src/main/resources/drill-sqlline.conf      |  6 +++++-
 .../drill/exec/client/DrillSqlLineApplicationTest.java    | 15 ++++++++++++---
 .../java/org/apache/drill/jdbc/DrillConnectionConfig.java |  2 +-
 .../apache/drill/jdbc/impl/AvaticaDrillSqlAccessor.java   |  3 +--
 .../org/apache/drill/jdbc/impl/DrillConnectionImpl.java   |  4 ++--
 .../main/java/org/apache/drill/jdbc/impl/DrillCursor.java |  2 +-
 .../apache/drill/jdbc/impl/DrillDatabaseMetaDataImpl.java |  4 +---
 .../java/org/apache/drill/jdbc/impl/DrillFactory.java     |  3 +--
 .../java/org/apache/drill/jdbc/impl/DrillHandler.java     |  6 ++----
 .../java/org/apache/drill/jdbc/impl/DrillMetaImpl.java    |  4 +---
 .../org/apache/drill/jdbc/impl/DrillResultSetImpl.java    | 10 +++++-----
 .../org/apache/drill/jdbc/impl/DrillStatementImpl.java    |  2 +-
 .../java/org/apache/drill/jdbc/impl/WrappedAccessor.java  |  2 +-
 pom.xml                                                   |  2 +-
 15 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillSqlLineApplication.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillSqlLineApplication.java
index 13d2b33..cc0426b 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillSqlLineApplication.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/client/DrillSqlLineApplication.java
@@ -19,10 +19,10 @@ package org.apache.drill.exec.client;
 
 import com.typesafe.config.Config;
 import com.typesafe.config.ConfigFactory;
-import jline.console.completer.StringsCompleter;
 import org.apache.drill.common.scanner.ClassPathScanner;
 import org.apache.drill.common.util.DrillVersionInfo;
 import org.apache.drill.shaded.guava.com.google.common.annotations.VisibleForTesting;
+import org.jline.reader.impl.completer.StringsCompleter;
 import sqlline.Application;
 import sqlline.CommandHandler;
 import sqlline.OutputFormat;
@@ -81,20 +81,25 @@ public class DrillSqlLineApplication extends Application {
   }
 
   @Override
-  public String getInfoMessage() throws Exception {
+  public String getInfoMessage() {
     if (config.hasPath(INFO_MESSAGE_TEMPLATE_CONF)) {
       String quote = "";
       if (config.hasPath(QUOTES_CONF)) {
         List<String> quotes = config.getStringList(QUOTES_CONF);
         quote = quotes.get(new Random().nextInt(quotes.size()));
       }
-      return String.format(config.getString(INFO_MESSAGE_TEMPLATE_CONF), DrillVersionInfo.getVersion(),
quote);
+      return String.format(config.getString(INFO_MESSAGE_TEMPLATE_CONF), getVersion(), quote);
     }
 
     return super.getInfoMessage();
   }
 
   @Override
+  public String getVersion() {
+    return DrillVersionInfo.getVersion();
+  }
+
+  @Override
   public Collection<String> initDrivers() {
     if (config.hasPath(DRIVERS_CONF)) {
       return config.getStringList(DRIVERS_CONF);
diff --git a/exec/java-exec/src/main/resources/drill-sqlline.conf b/exec/java-exec/src/main/resources/drill-sqlline.conf
index e081794..703944d 100644
--- a/exec/java-exec/src/main/resources/drill-sqlline.conf
+++ b/exec/java-exec/src/main/resources/drill-sqlline.conf
@@ -83,6 +83,10 @@ drill.sqlline {
   opts: {
     incremental: false,
     isolation: TRANSACTION_NONE,
-    maxWidth: 10000
+    maxWidth: 10000,
+    maxColumnWidth: 80,
+    colorScheme: obsidian,
+    # display null values for varchar / char / boolean as null
+    nullValue: "null"
   }
 }
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillSqlLineApplicationTest.java
b/exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillSqlLineApplicationTest.java
index 8d3c290..945df70 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillSqlLineApplicationTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/client/DrillSqlLineApplicationTest.java
@@ -17,8 +17,10 @@
  */
 package org.apache.drill.exec.client;
 
+import org.apache.drill.common.util.DrillVersionInfo;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import sqlline.Application;
 import sqlline.CommandHandler;
 import sqlline.OutputFormat;
 import sqlline.SqlLine;
@@ -38,7 +40,7 @@ import static org.junit.Assert.assertTrue;
 
 public class DrillSqlLineApplicationTest {
 
-  private static DrillSqlLineApplication application;
+  private static Application application;
 
   @BeforeClass
   public static void init() {
@@ -48,12 +50,17 @@ public class DrillSqlLineApplicationTest {
   }
 
   @Test
-  public void testInfoMessage() throws Exception {
+  public void testInfoMessage() {
     String infoMessage = application.getInfoMessage();
     assertThat(infoMessage, containsString("\"All code is guilty until proven innocent.\""));
   }
 
   @Test
+  public void testVersion() {
+    assertEquals(DrillVersionInfo.getVersion(), application.getVersion());
+  }
+
+  @Test
   public void testDrivers() {
     Collection<String> drivers = application.initDrivers();
     assertEquals(1L, drivers.size());
@@ -92,8 +99,10 @@ public class DrillSqlLineApplicationTest {
     SqlLineOpts opts = application.getOpts(sqlLine);
     assertFalse(opts.getIncremental());
     assertEquals("TRANSACTION_NONE", opts.getIsolation());
-    assertEquals(20_000, opts.getMaxWidth());
+    assertEquals(80, opts.getMaxColumnWidth());
     assertEquals(200, opts.getTimeout());
+    assertEquals("obsidian", opts.getColorScheme());
+    assertEquals("null", opts.getNullValue());
   }
 
   @Test
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionConfig.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionConfig.java
index 7067caf..c87fe71 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionConfig.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillConnectionConfig.java
@@ -35,7 +35,7 @@ import org.apache.calcite.avatica.ConnectionConfigImpl;
  *  <p>
  *    In the meantime, clients must not use the fact that
  *    {@code DrillConnectionConfig} currently extends
- *    {@link net.hydromatic.avatica.ConnectionConfigImpl}.  They must call only
+ *    {@link ConnectionConfigImpl}.  They must call only
  *    methods declared directly in DrillConnectionConfig (or inherited Object).
  *  </p>
  */
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/AvaticaDrillSqlAccessor.java
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/AvaticaDrillSqlAccessor.java
index 082e294..a4d9e96 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/AvaticaDrillSqlAccessor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/AvaticaDrillSqlAccessor.java
@@ -39,11 +39,10 @@ import org.apache.calcite.avatica.util.Cursor.Accessor;
 import org.apache.drill.exec.vector.accessor.SqlAccessor;
 import org.apache.drill.jdbc.InvalidCursorStateSqlException;
 
-
 // TODO:  Revisit adding null check for non-primitive types to SqlAccessor's
 // contract and classes generated by SqlAccessor template (DRILL-xxxx).
 
-class AvaticaDrillSqlAccessor implements Accessor {
+public class AvaticaDrillSqlAccessor implements Accessor {
   private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AvaticaDrillSqlAccessor.class);
 
   private final static byte PRIMITIVE_NUM_NULL_VALUE = 0;
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
index 820044e..df23f40 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java
@@ -81,7 +81,7 @@ import static org.apache.drill.exec.util.StoragePluginTestUtils.updateSchemaLoca
 // (Was abstract to avoid errors _here_ if newer versions of JDBC added
 // interface methods, but now newer versions would probably use Java 8's default
 // methods for compatibility.)
-class DrillConnectionImpl extends AvaticaConnection
+public class DrillConnectionImpl extends AvaticaConnection
                           implements DrillConnection {
   private static final org.slf4j.Logger logger =
       org.slf4j.LoggerFactory.getLogger(DrillConnection.class);
@@ -95,7 +95,7 @@ class DrillConnectionImpl extends AvaticaConnection
   private RemoteServiceSet serviceSet;
 
 
-  protected DrillConnectionImpl(DriverImpl driver, AvaticaFactory factory,
+  public DrillConnectionImpl(DriverImpl driver, AvaticaFactory factory,
                                 String url, Properties info) throws SQLException {
     super(driver, factory, url, info);
 
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java
index 888a909..7025f18 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java
@@ -59,7 +59,7 @@ import org.slf4j.Logger;
 import org.apache.drill.shaded.guava.com.google.common.collect.Queues;
 
 
-class DrillCursor implements Cursor {
+public class DrillCursor implements Cursor {
 
   ////////////////////////////////////////
   // ResultsListener:
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillDatabaseMetaDataImpl.java
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillDatabaseMetaDataImpl.java
index 78617b8..e080721 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillDatabaseMetaDataImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillDatabaseMetaDataImpl.java
@@ -56,9 +56,7 @@ import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableSet;
 /**
  * Drill's implementation of {@link java.sql.DatabaseMetaData}.
  */
-class DrillDatabaseMetaDataImpl extends AvaticaDatabaseMetaData
-                                implements DrillDatabaseMetaData {
-
+public class DrillDatabaseMetaDataImpl extends AvaticaDatabaseMetaData implements DrillDatabaseMetaData
{
 
   /**
    * Holds allowed conversion between SQL types
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillFactory.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillFactory.java
index b0a53d4..d87742e 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillFactory.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillFactory.java
@@ -24,9 +24,8 @@ import org.apache.calcite.avatica.UnregisteredDriver;
 import java.sql.SQLException;
 import java.util.Properties;
 
-
 /**
- * Partial implementation of {@link net.hydromatic.avatica.AvaticaFactory}
+ * Partial implementation of {@link AvaticaFactory}
  * (factory for main JDBC objects) for Drill's JDBC driver.
  * <p>
  *   Handles JDBC version number.
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillHandler.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillHandler.java
index 1c795dd..84fed2b 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillHandler.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillHandler.java
@@ -17,17 +17,15 @@
  */
 package org.apache.drill.jdbc.impl;
 
-import java.sql.SQLException;
-
 import org.apache.calcite.avatica.AvaticaConnection;
 import org.apache.calcite.avatica.AvaticaStatement;
 import org.apache.calcite.avatica.Handler;
 
-class DrillHandler implements Handler {
+public class DrillHandler implements Handler {
   static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillHandler.class);
 
   @Override
-  public void onConnectionInit(AvaticaConnection c) throws SQLException {
+  public void onConnectionInit(AvaticaConnection c) {
   }
 
   @Override
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java
index cf44cc9..2b61a6a 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java
@@ -64,9 +64,7 @@ import org.apache.drill.shaded.guava.com.google.common.base.Function;
 import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableMap;
 import org.apache.drill.shaded.guava.com.google.common.collect.Lists;
 
-
-
-class DrillMetaImpl extends MetaImpl {
+public class DrillMetaImpl extends MetaImpl {
   private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DrillMetaImpl.class);
 
   // TODO:  Use more central version of these constants if available.
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
index 835543c..e3cf4bb 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
@@ -58,13 +58,13 @@ import org.apache.drill.shaded.guava.com.google.common.base.Stopwatch;
 /**
  * Drill's implementation of {@link java.sql.ResultSet}.
  */
-class DrillResultSetImpl extends AvaticaResultSet implements DrillResultSet {
+public class DrillResultSetImpl extends AvaticaResultSet implements DrillResultSet {
   @SuppressWarnings("unused")
   private static final org.slf4j.Logger logger =
       org.slf4j.LoggerFactory.getLogger(DrillResultSetImpl.class);
 
   private final DrillConnectionImpl connection;
-  private volatile boolean hasPendingCancelationNotification = false;
+  private volatile boolean hasPendingCancellationNotification = false;
 
   //Timeout Support Variables
   private Stopwatch elapsedTimer;
@@ -90,8 +90,8 @@ class DrillResultSetImpl extends AvaticaResultSet implements DrillResultSet
{
   @Override
   protected void checkOpen() throws SQLException {
     if (isClosed()) {
-      if (cursor instanceof DrillCursor && hasPendingCancelationNotification) {
-        hasPendingCancelationNotification = false;
+      if (cursor instanceof DrillCursor && hasPendingCancellationNotification) {
+        hasPendingCancellationNotification = false;
         throw new ExecutionCanceledSqlException(
             "SQL statement execution canceled; ResultSet now closed.");
       } else {
@@ -119,7 +119,7 @@ class DrillResultSetImpl extends AvaticaResultSet implements DrillResultSet
{
   @Override
   protected void cancel() {
     if (cursor instanceof DrillCursor) {
-      hasPendingCancelationNotification = true;
+      hasPendingCancellationNotification = true;
       ((DrillCursor) cursor).cancel();
     } else {
       super.cancel();
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java
index 7255c75..e2747df 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillStatementImpl.java
@@ -34,7 +34,7 @@ import org.apache.drill.jdbc.DrillStatement;
 // (Was abstract to avoid errors _here_ if newer versions of JDBC added
 // interface methods, but now newer versions would probably use Java 8's default
 // methods for compatibility.)
-class DrillStatementImpl extends AvaticaStatement implements DrillStatement,
+public class DrillStatementImpl extends AvaticaStatement implements DrillStatement,
                                                              DrillRemoteStatement {
 
   private final DrillConnectionImpl connection;
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/WrappedAccessor.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/WrappedAccessor.java
index 8885206..22c2b96 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/WrappedAccessor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/WrappedAccessor.java
@@ -42,7 +42,7 @@ import org.apache.calcite.avatica.util.Cursor.Accessor;
  * instead
  *
  */
-class WrappedAccessor implements Accessor {
+public class WrappedAccessor implements Accessor {
   private final Accessor delegate;
 
   public WrappedAccessor(Accessor delegate) {
diff --git a/pom.xml b/pom.xml
index 6f80581..c9d2843 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
     <calcite.version>1.17.0-drill-r1</calcite.version>
     <avatica.version>1.12.0</avatica.version>
     <janino.version>3.0.11</janino.version>
-    <sqlline.version>1.5.0</sqlline.version>
+    <sqlline.version>1.6.0</sqlline.version>
     <jackson.version>2.9.5</jackson.version>
     <jackson.databind.version>2.9.5</jackson.databind.version>
     <zookeeper.version>3.4.12</zookeeper.version>


Mime
View raw message