[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-03-02 Thread Sudheesh Katkam (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15893652#comment-15893652
 ] 

Sudheesh Katkam commented on DRILL-4730:


Fixed in 
[17f888d|https://github.com/apache/drill/commit/17f888d9058be2be8953cb1ea5b37297b7d2fef3]

> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>  Labels: ready-to-commit
> Fix For: 1.10.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-03-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15892991#comment-15892991
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user asfgit closed the pull request at:

https://github.com/apache/drill/pull/613


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>  Labels: ready-to-commit
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-03-01 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15890208#comment-15890208
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on the issue:

https://github.com/apache/drill/pull/613
  
yes, pull requests have been kept in sync.


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>  Labels: ready-to-commit
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15887768#comment-15887768
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on the issue:

https://github.com/apache/drill/pull/613
  
+1


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15877215#comment-15877215
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r102364337
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java ---
@@ -78,19 +111,237 @@ private MetaResultSet s(String s) {
 }
   }
 
+  /** Information about type mapping. */
+  private static class TypeInfo {
+private static Map, TypeInfo> MAPPING = 
ImmutableMap., TypeInfo> builder()
+.put(boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Byte.TYPE, of(Types.TINYINT, "TINYINT"))
+.put(Byte.class, of(Types.TINYINT, "TINYINT"))
+.put(Short.TYPE, of(Types.SMALLINT, "SMALLINT"))
+.put(Short.class, of(Types.SMALLINT, "SMALLINT"))
+.put(Integer.TYPE, of(Types.INTEGER, "INTEGER"))
+.put(Integer.class, of(Types.INTEGER, "INTEGER"))
+.put(Long.TYPE,  of(Types.BIGINT, "BIGINT"))
+.put(Long.class, of(Types.BIGINT, "BIGINT"))
+.put(Float.TYPE, of(Types.FLOAT, "FLOAT"))
+.put(Float.class,  of(Types.FLOAT, "FLOAT"))
+.put(Double.TYPE,  of(Types.DOUBLE, "DOUBLE"))
+.put(Double.class, of(Types.DOUBLE, "DOUBLE"))
+.put(String.class, of(Types.VARCHAR, "CHARACTER VARYING"))
+.put(java.sql.Date.class, of(Types.DATE, "DATE"))
+.put(Time.class, of(Types.TIME, "TIME"))
+.put(Timestamp.class, of(Types.TIMESTAMP, "TIMESTAMP"))
+.build();
+
+private final int sqlType;
+private final String sqlTypeName;
+
+public TypeInfo(int sqlType, String sqlTypeName) {
+  this.sqlType = sqlType;
+  this.sqlTypeName = sqlTypeName;
+}
 
+private static TypeInfo of(int sqlType, String sqlTypeName) {
+  return new TypeInfo(sqlType, sqlTypeName);
+}
 
-  @Override
-  protected  MetaResultSet createEmptyResultSet(Class clazz) {
-return s(
-"SELECT '' AS `Interim zero-row result set` "  // dummy row type
-+ "FROM INFORMATION_SCHEMA.CATALOGS "  // any table
-+ "LIMIT 0"// zero rows
-);
+public static TypeInfo get(Class clazz) {
+  return MAPPING.get(clazz);
+}
   }
 
-  @Override
-  public MetaResultSet getTables(String catalog, final Pat schemaPattern, 
final Pat tableNamePattern,
+  /** Metadata describing a column.
+   * Copied from Avatica with several fixes
+   * */
+  public static class MetaColumn implements Named {
+public final String tableCat;
+public final String tableSchem;
+public final String tableName;
+public final String columnName;
+public final int dataType;
+public final String typeName;
+public final Integer columnSize;
+public final Integer bufferLength = null;
+public final Integer decimalDigits;
+public final Integer numPrecRadix;
+public final int nullable;
+public final String remarks = null;
+public final String columnDef = null;
+public final Integer sqlDataType = null;
+public final Integer sqlDatetimeSub = null;
+public final Integer charOctetLength;
+public final int ordinalPosition;
+@NotNull
+public final String isNullable;
+public final String scopeCatalog = null;
+public final String scopeSchema = null;
+public final String scopeTable = null;
+public final Short sourceDataType = null;
+@NotNull
+public final String isAutoincrement = "";
+@NotNull
+public final String isGeneratedcolumn = "";
+
+public MetaColumn(
+String tableCat,
+String tableSchem,
+String tableName,
+String columnName,
+int dataType,
+String typeName,
+Integer columnSize,
+Integer decimalDigits,
+Integer numPrecRadix,
+int nullable,
+Integer charOctetLength,
+int ordinalPosition,
+String isNullable) {
+  this.tableCat = tableCat;
+  this.tableSchem = tableSchem;
+  this.tableName = tableName;
+  this.columnName = columnName;
+  this.dataType = dataType;
+  this.typeName = typeName;
+  this.columnSize = columnSize;
+  this.decimalDigits = decimalDigits;
+  this.numPrecRadix = numPrecRadix;
+  this.nullable = nullable;
+  th

[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15877203#comment-15877203
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r102363803
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java ---
@@ -24,33 +24,260 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.calcite.avatica.AvaticaResultSet;
+import org.apache.calcite.avatica.AvaticaStatement;
 import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.Meta.Signature;
 import org.apache.calcite.avatica.util.ArrayImpl.Factory;
 import org.apache.calcite.avatica.util.Cursor;
 import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.client.DrillClient;
 import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.proto.UserBitShared.QueryId;
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+import org.apache.drill.exec.proto.UserBitShared.QueryType;
+import org.apache.drill.exec.proto.helper.QueryIdHelper;
 import org.apache.drill.exec.record.BatchSchema;
 import org.apache.drill.exec.record.RecordBatchLoader;
+import org.apache.drill.exec.rpc.ConnectionThrottle;
 import org.apache.drill.exec.rpc.user.QueryDataBatch;
+import org.apache.drill.exec.rpc.user.UserResultsListener;
 import org.apache.drill.exec.store.ischema.InfoSchemaConstants;
+import org.apache.drill.jdbc.SchemaChangeListener;
 import org.slf4j.Logger;
 
+import com.google.common.collect.Queues;
+
 
 class DrillCursor implements Cursor {
+
+  
+  // ResultsListener:
+  static class ResultsListener implements UserResultsListener {
+private static final org.slf4j.Logger logger =
+org.slf4j.LoggerFactory.getLogger(ResultsListener.class);
+
+private static volatile int nextInstanceId = 1;
+
+/** (Just for logging.) */
+private final int instanceId;
+
+private final int batchQueueThrottlingThreshold;
+
+/** (Just for logging.) */
+private volatile QueryId queryId;
+
+/** (Just for logging.) */
+private int lastReceivedBatchNumber;
+/** (Just for logging.) */
+private int lastDequeuedBatchNumber;
+
+private volatile UserException executionFailureException;
+
+// TODO:  Revisit "completed".  Determine and document exactly what it
+// means.  Some uses imply that it means that incoming messages 
indicate
+// that the _query_ has _terminated_ (not necessarily _completing_
+// normally), while some uses imply that it's some other state of the
+// ResultListener.  Some uses seem redundant.)
+volatile boolean completed = false;
+
+/** Whether throttling of incoming data is active. */
+private final AtomicBoolean throttled = new AtomicBoolean( false );
+private volatile ConnectionThrottle throttle;
+
+private volatile boolean closed = false;
+
+private final CountDownLatch firstMessageReceived = new 
CountDownLatch(1);
+
+final LinkedBlockingDeque batchQueue =
+Queues.newLinkedBlockingDeque();
+
+
+/**
+ * ...
+ * @param  batchQueueThrottlingThreshold
+ * queue size threshold for throttling server
+ */
+ResultsListener( int batchQueueThrottlingThreshold ) {
+  instanceId = nextInstanceId++;
+  this.batchQueueThrottlingThreshold = batchQueueThrottlingThreshold;
+  logger.debug( "[#{}] Query listener created.", instanceId );
+}
+
+/**
+ * Starts throttling if not currently throttling.
+ * @param  throttle  the "throttlable" object to throttle
+ * @return  true if actually started (wasn't throttling already)
+ */
+private boolean startThrottlingIfNot( ConnectionThrottle throttle ) {
+  final boolean started = throttled.compareAndSet( false, true );
+  if ( started ) {
+this.throttle = throttle;
+throttle.setAutoRead(false);
+  }
+  return started;
+}
+
+/**
+ * Stops throttling if currently throttling.
+ * @ret

[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-21 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15877189#comment-15877189
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r102363018
  
--- Diff: 
exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
 ---
@@ -2712,22 +2712,18 @@ public void 
test_SOURCE_DATA_TYPE_hasSameNameAndLabel() throws SQLException {
 
   @Test
   public void test_SOURCE_DATA_TYPE_hasRightTypeString() throws 
SQLException {
-// TODO(DRILL-2135):  Resolve workaround:
-//assertThat( rsMetadata.getColumnTypeName( 22 ), equalTo( "SMALLINT" 
) );
-assertThat( rowsMetadata.getColumnTypeName( 22 ), equalTo( "INTEGER" ) 
);
+assertThat( rowsMetadata.getColumnTypeName( 22 ), equalTo( "SMALLINT" 
) );
--- End diff --

no, it isn't unfortunately


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866110#comment-15866110
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r86651825
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillCursor.java ---
@@ -24,33 +24,260 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.calcite.avatica.AvaticaResultSet;
+import org.apache.calcite.avatica.AvaticaStatement;
 import org.apache.calcite.avatica.ColumnMetaData;
+import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.Meta.Signature;
 import org.apache.calcite.avatica.util.ArrayImpl.Factory;
 import org.apache.calcite.avatica.util.Cursor;
 import org.apache.drill.common.exceptions.UserException;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.client.DrillClient;
 import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.proto.UserBitShared.QueryId;
+import org.apache.drill.exec.proto.UserBitShared.QueryResult.QueryState;
+import org.apache.drill.exec.proto.UserBitShared.QueryType;
+import org.apache.drill.exec.proto.helper.QueryIdHelper;
 import org.apache.drill.exec.record.BatchSchema;
 import org.apache.drill.exec.record.RecordBatchLoader;
+import org.apache.drill.exec.rpc.ConnectionThrottle;
 import org.apache.drill.exec.rpc.user.QueryDataBatch;
+import org.apache.drill.exec.rpc.user.UserResultsListener;
 import org.apache.drill.exec.store.ischema.InfoSchemaConstants;
+import org.apache.drill.jdbc.SchemaChangeListener;
 import org.slf4j.Logger;
 
+import com.google.common.collect.Queues;
+
 
 class DrillCursor implements Cursor {
+
+  
+  // ResultsListener:
+  static class ResultsListener implements UserResultsListener {
+private static final org.slf4j.Logger logger =
+org.slf4j.LoggerFactory.getLogger(ResultsListener.class);
+
+private static volatile int nextInstanceId = 1;
+
+/** (Just for logging.) */
+private final int instanceId;
+
+private final int batchQueueThrottlingThreshold;
+
+/** (Just for logging.) */
+private volatile QueryId queryId;
+
+/** (Just for logging.) */
+private int lastReceivedBatchNumber;
+/** (Just for logging.) */
+private int lastDequeuedBatchNumber;
+
+private volatile UserException executionFailureException;
+
+// TODO:  Revisit "completed".  Determine and document exactly what it
+// means.  Some uses imply that it means that incoming messages 
indicate
+// that the _query_ has _terminated_ (not necessarily _completing_
+// normally), while some uses imply that it's some other state of the
+// ResultListener.  Some uses seem redundant.)
+volatile boolean completed = false;
+
+/** Whether throttling of incoming data is active. */
+private final AtomicBoolean throttled = new AtomicBoolean( false );
+private volatile ConnectionThrottle throttle;
+
+private volatile boolean closed = false;
+
+private final CountDownLatch firstMessageReceived = new 
CountDownLatch(1);
+
+final LinkedBlockingDeque batchQueue =
+Queues.newLinkedBlockingDeque();
+
+
+/**
+ * ...
+ * @param  batchQueueThrottlingThreshold
+ * queue size threshold for throttling server
+ */
+ResultsListener( int batchQueueThrottlingThreshold ) {
+  instanceId = nextInstanceId++;
+  this.batchQueueThrottlingThreshold = batchQueueThrottlingThreshold;
+  logger.debug( "[#{}] Query listener created.", instanceId );
+}
+
+/**
+ * Starts throttling if not currently throttling.
+ * @param  throttle  the "throttlable" object to throttle
+ * @return  true if actually started (wasn't throttling already)
+ */
+private boolean startThrottlingIfNot( ConnectionThrottle throttle ) {
+  final boolean started = throttled.compareAndSet( false, true );
+  if ( started ) {
+this.throttle = throttle;
+throttle.setAutoRead(false);
+  }
+  return started;
+}
+
+/**
+ * Stops throttling if currently throttling.
+ * 

[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866109#comment-15866109
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r86275226
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java ---
@@ -61,77 +91,271 @@ private static Signature newSignature(String sql) {
 sql,
 Collections. emptyList(),
 Collections.emptyMap(),
-CursorFactory.OBJECT);
+null // CursorFactory set to null, as SQL requests use DrillCursor
+);
   }
 
-  private MetaResultSet s(String s) {
-try {
-  logger.debug("Running {}", s);
-
-  AvaticaStatement statement = connection.createStatement();
-  return MetaResultSet.create(connection.id, statement.getId(), true,
-  newSignature(s), null);
-} catch (Exception e) {
-  // Wrap in RuntimeException because Avatica's abstract method 
declarations
-  // didn't allow for SQLException!
-  throw new DrillRuntimeException("Failure while attempting to get 
DatabaseMetadata.", e);
+
+  /** Information about type mapping. */
+  private static class TypeInfo {
+private static Map, TypeInfo> MAPPING = 
ImmutableMap., TypeInfo> builder()
+.put(boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
--- End diff --

Given this, how about `int.class` and others?



> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866108#comment-15866108
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r100422973
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java ---
@@ -78,19 +111,237 @@ private MetaResultSet s(String s) {
 }
   }
 
+  /** Information about type mapping. */
+  private static class TypeInfo {
+private static Map, TypeInfo> MAPPING = 
ImmutableMap., TypeInfo> builder()
--- End diff --

final


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866111#comment-15866111
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r100428330
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java ---
@@ -78,19 +111,237 @@ private MetaResultSet s(String s) {
 }
   }
 
+  /** Information about type mapping. */
+  private static class TypeInfo {
+private static Map, TypeInfo> MAPPING = 
ImmutableMap., TypeInfo> builder()
+.put(boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Byte.TYPE, of(Types.TINYINT, "TINYINT"))
+.put(Byte.class, of(Types.TINYINT, "TINYINT"))
+.put(Short.TYPE, of(Types.SMALLINT, "SMALLINT"))
+.put(Short.class, of(Types.SMALLINT, "SMALLINT"))
+.put(Integer.TYPE, of(Types.INTEGER, "INTEGER"))
+.put(Integer.class, of(Types.INTEGER, "INTEGER"))
+.put(Long.TYPE,  of(Types.BIGINT, "BIGINT"))
+.put(Long.class, of(Types.BIGINT, "BIGINT"))
+.put(Float.TYPE, of(Types.FLOAT, "FLOAT"))
+.put(Float.class,  of(Types.FLOAT, "FLOAT"))
+.put(Double.TYPE,  of(Types.DOUBLE, "DOUBLE"))
+.put(Double.class, of(Types.DOUBLE, "DOUBLE"))
+.put(String.class, of(Types.VARCHAR, "CHARACTER VARYING"))
+.put(java.sql.Date.class, of(Types.DATE, "DATE"))
+.put(Time.class, of(Types.TIME, "TIME"))
+.put(Timestamp.class, of(Types.TIMESTAMP, "TIMESTAMP"))
+.build();
+
+private final int sqlType;
+private final String sqlTypeName;
+
+public TypeInfo(int sqlType, String sqlTypeName) {
+  this.sqlType = sqlType;
+  this.sqlTypeName = sqlTypeName;
+}
 
+private static TypeInfo of(int sqlType, String sqlTypeName) {
+  return new TypeInfo(sqlType, sqlTypeName);
+}
 
-  @Override
-  protected  MetaResultSet createEmptyResultSet(Class clazz) {
-return s(
-"SELECT '' AS `Interim zero-row result set` "  // dummy row type
-+ "FROM INFORMATION_SCHEMA.CATALOGS "  // any table
-+ "LIMIT 0"// zero rows
-);
+public static TypeInfo get(Class clazz) {
+  return MAPPING.get(clazz);
+}
   }
 
-  @Override
-  public MetaResultSet getTables(String catalog, final Pat schemaPattern, 
final Pat tableNamePattern,
+  /** Metadata describing a column.
+   * Copied from Avatica with several fixes
+   * */
+  public static class MetaColumn implements Named {
+public final String tableCat;
+public final String tableSchem;
+public final String tableName;
+public final String columnName;
+public final int dataType;
+public final String typeName;
+public final Integer columnSize;
+public final Integer bufferLength = null;
+public final Integer decimalDigits;
+public final Integer numPrecRadix;
+public final int nullable;
+public final String remarks = null;
+public final String columnDef = null;
+public final Integer sqlDataType = null;
+public final Integer sqlDatetimeSub = null;
+public final Integer charOctetLength;
+public final int ordinalPosition;
+@NotNull
+public final String isNullable;
+public final String scopeCatalog = null;
+public final String scopeSchema = null;
+public final String scopeTable = null;
+public final Short sourceDataType = null;
+@NotNull
+public final String isAutoincrement = "";
+@NotNull
+public final String isGeneratedcolumn = "";
+
+public MetaColumn(
+String tableCat,
+String tableSchem,
+String tableName,
+String columnName,
+int dataType,
+String typeName,
+Integer columnSize,
+Integer decimalDigits,
+Integer numPrecRadix,
+int nullable,
+Integer charOctetLength,
+int ordinalPosition,
+String isNullable) {
+  this.tableCat = tableCat;
+  this.tableSchem = tableSchem;
+  this.tableName = tableName;
+  this.columnName = columnName;
+  this.dataType = dataType;
+  this.typeName = typeName;
+  this.columnSize = columnSize;
+  this.decimalDigits = decimalDigits;
+  this.numPrecRadix = numPrecRadix;
+  this.nullable = nullable;
+   

[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866107#comment-15866107
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r86650548
  
--- Diff: 
exec/jdbc/src/test/java/org/apache/drill/jdbc/DatabaseMetaDataGetColumnsTest.java
 ---
@@ -2712,22 +2712,18 @@ public void 
test_SOURCE_DATA_TYPE_hasSameNameAndLabel() throws SQLException {
 
   @Test
   public void test_SOURCE_DATA_TYPE_hasRightTypeString() throws 
SQLException {
-// TODO(DRILL-2135):  Resolve workaround:
-//assertThat( rsMetadata.getColumnTypeName( 22 ), equalTo( "SMALLINT" 
) );
-assertThat( rowsMetadata.getColumnTypeName( 22 ), equalTo( "INTEGER" ) 
);
+assertThat( rowsMetadata.getColumnTypeName( 22 ), equalTo( "SMALLINT" 
) );
--- End diff --

Is [DRILL-2135](https://issues.apache.org/jira/browse/DRILL-2135) being 
resolved as well?



> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866105#comment-15866105
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r86651605
  
--- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/ops/ViewExpansionContext.java
 ---
@@ -70,20 +73,25 @@
 public class ViewExpansionContext {
   private static final org.slf4j.Logger logger = 
org.slf4j.LoggerFactory.getLogger(ViewExpansionContext.class);
 
-  private final QueryContext queryContext;
+  private SchemaConfigInfoProvider schemaConfigInfoProvider;
--- End diff --

final



> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-14 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15866106#comment-15866106
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on a diff in the pull request:

https://github.com/apache/drill/pull/613#discussion_r100425035
  
--- Diff: 
exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java ---
@@ -78,19 +111,237 @@ private MetaResultSet s(String s) {
 }
   }
 
+  /** Information about type mapping. */
+  private static class TypeInfo {
+private static Map, TypeInfo> MAPPING = 
ImmutableMap., TypeInfo> builder()
+.put(boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Boolean.class, of(Types.BOOLEAN, "BOOLEAN"))
+.put(Byte.TYPE, of(Types.TINYINT, "TINYINT"))
+.put(Byte.class, of(Types.TINYINT, "TINYINT"))
+.put(Short.TYPE, of(Types.SMALLINT, "SMALLINT"))
+.put(Short.class, of(Types.SMALLINT, "SMALLINT"))
+.put(Integer.TYPE, of(Types.INTEGER, "INTEGER"))
+.put(Integer.class, of(Types.INTEGER, "INTEGER"))
+.put(Long.TYPE,  of(Types.BIGINT, "BIGINT"))
+.put(Long.class, of(Types.BIGINT, "BIGINT"))
+.put(Float.TYPE, of(Types.FLOAT, "FLOAT"))
+.put(Float.class,  of(Types.FLOAT, "FLOAT"))
+.put(Double.TYPE,  of(Types.DOUBLE, "DOUBLE"))
+.put(Double.class, of(Types.DOUBLE, "DOUBLE"))
+.put(String.class, of(Types.VARCHAR, "CHARACTER VARYING"))
+.put(java.sql.Date.class, of(Types.DATE, "DATE"))
+.put(Time.class, of(Types.TIME, "TIME"))
+.put(Timestamp.class, of(Types.TIMESTAMP, "TIMESTAMP"))
+.build();
+
+private final int sqlType;
+private final String sqlTypeName;
+
+public TypeInfo(int sqlType, String sqlTypeName) {
+  this.sqlType = sqlType;
+  this.sqlTypeName = sqlTypeName;
+}
 
+private static TypeInfo of(int sqlType, String sqlTypeName) {
+  return new TypeInfo(sqlType, sqlTypeName);
+}
 
-  @Override
-  protected  MetaResultSet createEmptyResultSet(Class clazz) {
-return s(
-"SELECT '' AS `Interim zero-row result set` "  // dummy row type
-+ "FROM INFORMATION_SCHEMA.CATALOGS "  // any table
-+ "LIMIT 0"// zero rows
-);
+public static TypeInfo get(Class clazz) {
+  return MAPPING.get(clazz);
+}
   }
 
-  @Override
-  public MetaResultSet getTables(String catalog, final Pat schemaPattern, 
final Pat tableNamePattern,
+  /** Metadata describing a column.
+   * Copied from Avatica with several fixes
+   * */
+  public static class MetaColumn implements Named {
+public final String tableCat;
+public final String tableSchem;
+public final String tableName;
+public final String columnName;
+public final int dataType;
+public final String typeName;
+public final Integer columnSize;
+public final Integer bufferLength = null;
+public final Integer decimalDigits;
+public final Integer numPrecRadix;
+public final int nullable;
+public final String remarks = null;
+public final String columnDef = null;
+public final Integer sqlDataType = null;
+public final Integer sqlDatetimeSub = null;
+public final Integer charOctetLength;
+public final int ordinalPosition;
+@NotNull
+public final String isNullable;
+public final String scopeCatalog = null;
+public final String scopeSchema = null;
+public final String scopeTable = null;
+public final Short sourceDataType = null;
+@NotNull
+public final String isAutoincrement = "";
+@NotNull
+public final String isGeneratedcolumn = "";
+
+public MetaColumn(
+String tableCat,
+String tableSchem,
+String tableName,
+String columnName,
+int dataType,
+String typeName,
+Integer columnSize,
+Integer decimalDigits,
+Integer numPrecRadix,
+int nullable,
+Integer charOctetLength,
+int ordinalPosition,
+String isNullable) {
+  this.tableCat = tableCat;
+  this.tableSchem = tableSchem;
+  this.tableName = tableName;
+  this.columnName = columnName;
+  this.dataType = dataType;
+  this.typeName = typeName;
+  this.columnSize = columnSize;
+  this.decimalDigits = decimalDigits;
+  this.numPrecRadix = numPrecRadix;
+  this.nullable = nullable;
+   

[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2017-02-06 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15854492#comment-15854492
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on the issue:

https://github.com/apache/drill/pull/613
  
@sudheeshkatkam can you please give it another review?


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-11-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15638354#comment-15638354
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on the issue:

https://github.com/apache/drill/pull/613
  
I added the necessary fallbacks for prepared statement and metadata, so a 
new client should now be able to talk with an old server without adverse 
effects.

I would prefer that this change to be in this release, to match the state 
of the C++ client, but I realized this is getting late.


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-11-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15638146#comment-15638146
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on the issue:

https://github.com/apache/drill/pull/613
  
I just realized you mentioned about this on the mailing list. In that case, 
let's defer committing this pull request to the next release.

> That said, the metadata change is not merged yet (and I will add the extra
> logic), which is not the case regarding prepared statement support.


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-11-04 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15638110#comment-15638110
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on the issue:

https://github.com/apache/drill/pull/613
  
@laurentgo thanks for splitting the commit!

Looks like queries are replaced by API calls in the core changes, so can 
the new driver talk to old servers?


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-11-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15631031#comment-15631031
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user laurentgo commented on the issue:

https://github.com/apache/drill/pull/613
  
the only "refactoring" I can think of is between DrillCursor and 
DrillResultSetImpl, anything else is related to the feature. I'll try to split 
it, but hopefully in the current state, it should still be pretty readable.


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-11-02 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15630817#comment-15630817
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

Github user sudheeshkatkam commented on the issue:

https://github.com/apache/drill/pull/613
  
I started looking into this. Can you please split the commit into two 
(refactoring changes, and the core changes that use new API) for quicker review?


> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (DRILL-4730) Update JDBC DatabaseMetaData implementation to use new Metadata APIs

2016-10-12 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/DRILL-4730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15570159#comment-15570159
 ] 

ASF GitHub Bot commented on DRILL-4730:
---

GitHub user laurentgo opened a pull request:

https://github.com/apache/drill/pull/613

DRILL-4730: Update JDBC DatabaseMetaData implementation to use new Metadata 
APIs

Update JDBC driver to use Metadata APIs instead of executing SQL queries

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/laurentgo/drill laurent/DRILL-4730

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/drill/pull/613.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #613






> Update JDBC DatabaseMetaData implementation to use new Metadata APIs
> 
>
> Key: DRILL-4730
> URL: https://issues.apache.org/jira/browse/DRILL-4730
> Project: Apache Drill
>  Issue Type: Sub-task
>  Components: Client - JDBC
>Reporter: Venki Korukanti
>Assignee: Laurent Goujon
> Fix For: 1.9.0
>
>
> DRILL-4728 is going to add support for new metadata APIs. Replace the 
> INFORMATION_SCHEMA queries used to get the metadata with the new APIs 
> provided in Java client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)