aboutsummaryrefslogtreecommitdiff
path: root/exec/jdbc/src/main/java
diff options
context:
space:
mode:
authorRoman Kulyk <rom.kulyk@gmail.com>2017-08-29 14:10:24 +0000
committerVolodymyr Vysotskyi <vvovyk@gmail.com>2018-01-16 12:10:13 +0200
commit9fabb612f16f6f541b3bde68ad7d734cad26df33 (patch)
treede9369679724aaf5ccd29d6f0b7e2b12e7506b9c /exec/jdbc/src/main/java
parent450e67094eb6e9a6484d7f86c49b51c77a08d7b2 (diff)
DRILL-3993: Changes to support Calcite 1.13
- fixed all compiling errors (main changes were: Maven changes, chenges RelNode -> RelRoot, implementing some new methods from updated interfaces, chenges some literals, logger changes); - fixed unexpected column errors, validation errors and assertion errors after Calcite update; - fixed describe table/schema statement according to updated logic; - added fixes with time-intervals; - changed precision of BINARY to 65536 (was 1048576) according to updated logic (Calcite overrides bigger precision to own maxPrecision); - ignored some incorrect tests with DRILL-3244; - changed "Table not found" message to "Object not found within" according to new Calcite changes.
Diffstat (limited to 'exec/jdbc/src/main/java')
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillConnectionImpl.java12
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillJdbc41Factory.java6
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillMetaImpl.java73
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java18
-rw-r--r--exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java7
5 files changed, 87 insertions, 29 deletions
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 a2b921146..689041c57 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
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -46,6 +46,8 @@ import org.apache.calcite.avatica.AvaticaFactory;
import org.apache.calcite.avatica.AvaticaStatement;
import org.apache.calcite.avatica.Meta.ExecuteResult;
import org.apache.calcite.avatica.Meta.MetaResultSet;
+import org.apache.calcite.avatica.NoSuchStatementException;
+import org.apache.calcite.avatica.QueryState;
import org.apache.calcite.avatica.UnregisteredDriver;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.common.exceptions.DrillRuntimeException;
@@ -180,16 +182,16 @@ class DrillConnectionImpl extends AvaticaConnection
@Override
- protected ResultSet createResultSet(MetaResultSet metaResultSet) throws SQLException {
- return super.createResultSet(metaResultSet);
+ protected ResultSet createResultSet(MetaResultSet metaResultSet, QueryState state) throws SQLException {
+ return super.createResultSet(metaResultSet, state);
}
@Override
protected ExecuteResult prepareAndExecuteInternal(AvaticaStatement statement, String sql, long maxRowCount)
- throws SQLException {
+ throws SQLException, NoSuchStatementException {
try {
return super.prepareAndExecuteInternal(statement, sql, maxRowCount);
- } catch(RuntimeException e) {
+ } catch (RuntimeException e) {
Throwables.propagateIfInstanceOf(e.getCause(), SQLException.class);
throw e;
}
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillJdbc41Factory.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillJdbc41Factory.java
index 629e47be3..38715e991 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillJdbc41Factory.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillJdbc41Factory.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -34,6 +34,7 @@ import org.apache.calcite.avatica.AvaticaStatement;
import org.apache.calcite.avatica.Helper;
import org.apache.calcite.avatica.Meta;
import org.apache.calcite.avatica.Meta.StatementHandle;
+import org.apache.calcite.avatica.QueryState;
import org.apache.drill.exec.client.DrillClient;
import org.apache.drill.exec.client.ServerMethod;
import org.apache.drill.exec.proto.UserProtos.CreatePreparedStatementResp;
@@ -170,12 +171,13 @@ public class DrillJdbc41Factory extends DrillFactory {
@Override
public DrillResultSetImpl newResultSet(AvaticaStatement statement,
+ QueryState state,
Meta.Signature signature,
TimeZone timeZone,
Meta.Frame firstFrame) {
final ResultSetMetaData metaData =
newResultSetMetaData(statement, signature);
- return new DrillResultSetImpl(statement, signature, metaData, timeZone, firstFrame);
+ return new DrillResultSetImpl(statement, state, signature, metaData, timeZone, firstFrame);
}
@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 b78e93a55..810ffef8c 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
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -38,6 +38,10 @@ import org.apache.calcite.avatica.ColumnMetaData;
import org.apache.calcite.avatica.ColumnMetaData.StructType;
import org.apache.calcite.avatica.Meta;
import org.apache.calcite.avatica.MetaImpl;
+import org.apache.calcite.avatica.MissingResultsException;
+import org.apache.calcite.avatica.NoSuchStatementException;
+import org.apache.calcite.avatica.QueryState;
+import org.apache.calcite.avatica.remote.TypedValue;
import org.apache.drill.common.exceptions.DrillRuntimeException;
import org.apache.drill.common.util.DrillStringUtils;
import org.apache.drill.exec.client.ServerMethod;
@@ -92,8 +96,8 @@ class DrillMetaImpl extends MetaImpl {
sql,
Collections.<AvaticaParameter> emptyList(),
Collections.<String, Object>emptyMap(),
- null // CursorFactory set to null, as SQL requests use DrillCursor
- );
+ null, // CursorFactory set to null, as SQL requests use DrillCursor
+ Meta.StatementType.SELECT);
}
private MetaResultSet s(String s) {
@@ -322,7 +326,7 @@ class DrillMetaImpl extends MetaImpl {
StructType fieldMetaData = drillFieldMetaData(clazz);
Meta.Signature signature = Meta.Signature.create(
fieldMetaData.columns, "",
- Collections.<AvaticaParameter>emptyList(), CursorFactory.record(clazz));
+ Collections.<AvaticaParameter>emptyList(), CursorFactory.record(clazz), Meta.StatementType.SELECT);
AvaticaStatement statement = connection.createStatement();
return MetaResultSet.create(connection.id, statement.getId(), true,
@@ -419,8 +423,11 @@ class DrillMetaImpl extends MetaImpl {
* Implements {@link DatabaseMetaData#getTables}.
*/
@Override
- public MetaResultSet getTables(String catalog, final Pat schemaPattern, final Pat tableNamePattern,
- final List<String> typeList) {
+ public MetaResultSet getTables(ConnectionHandle ch,
+ String catalog,
+ Pat schemaPattern,
+ Pat tableNamePattern,
+ List<String> typeList) {
if (connection.getConfig().isServerMetadataDisabled() || ! connection.getClient().getSupportedMethods().contains(ServerMethod.GET_TABLES)) {
return clientGetTables(catalog, schemaPattern, tableNamePattern, typeList);
}
@@ -962,8 +969,7 @@ class DrillMetaImpl extends MetaImpl {
* Implements {@link DatabaseMetaData#getColumns}.
*/
@Override
- public MetaResultSet getColumns(String catalog, Pat schemaPattern,
- Pat tableNamePattern, Pat columnNamePattern) {
+ public MetaResultSet getColumns(ConnectionHandle ch, String catalog, Pat schemaPattern, Pat tableNamePattern, Pat columnNamePattern) {
if (connection.getConfig().isServerMetadataDisabled() || ! connection.getClient().getSupportedMethods().contains(ServerMethod.GET_COLUMNS)) {
return clientGetColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern);
}
@@ -1022,7 +1028,7 @@ class DrillMetaImpl extends MetaImpl {
* Implements {@link DatabaseMetaData#getSchemas}.
*/
@Override
- public MetaResultSet getSchemas(String catalog, Pat schemaPattern) {
+ public MetaResultSet getSchemas(ConnectionHandle ch, String catalog, Pat schemaPattern) {
if (connection.getConfig().isServerMetadataDisabled() || ! connection.getClient().getSupportedMethods().contains(ServerMethod.GET_SCHEMAS)) {
return clientGetSchemas(catalog, schemaPattern);
}
@@ -1069,7 +1075,7 @@ class DrillMetaImpl extends MetaImpl {
* Implements {@link DatabaseMetaData#getCatalogs}.
*/
@Override
- public MetaResultSet getCatalogs() {
+ public MetaResultSet getCatalogs(ConnectionHandle ch) {
if (connection.getConfig().isServerMetadataDisabled() || ! connection.getClient().getSupportedMethods().contains(ServerMethod.GET_CATALOGS)) {
return clientGetCatalogs();
}
@@ -1106,7 +1112,54 @@ class DrillMetaImpl extends MetaImpl {
}
@Override
+ public ExecuteResult prepareAndExecute(final StatementHandle handle, final String sql, final long maxRowCount,
+ int maxRowsInFirstFrame, final PrepareCallback callback) throws NoSuchStatementException {
+ return prepareAndExecute(handle, sql, maxRowCount, callback);
+ }
+
+ @Override
+ public ExecuteBatchResult prepareAndExecuteBatch(StatementHandle statementHandle, List<String> list) throws NoSuchStatementException {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public ExecuteBatchResult executeBatch(StatementHandle statementHandle, List<List<TypedValue>> list) throws NoSuchStatementException {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public Frame fetch(StatementHandle statementHandle, long l, int i) throws NoSuchStatementException, MissingResultsException {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public ExecuteResult execute(StatementHandle statementHandle, List<TypedValue> list, long l) throws NoSuchStatementException {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public ExecuteResult execute(StatementHandle statementHandle, List<TypedValue> list, int i) throws NoSuchStatementException {
+ return null;
+ }
+
+ @Override
public void closeStatement(StatementHandle h) {
// Nothing
}
+
+ @Override
+ public boolean syncResults(StatementHandle statementHandle, QueryState queryState, long l) throws NoSuchStatementException {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public void commit(ConnectionHandle connectionHandle) {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
+ @Override
+ public void rollback(ConnectionHandle connectionHandle) {
+ throw new UnsupportedOperationException(this.getClass().getSimpleName());
+ }
+
}
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
index f1ba4c1ac..a45412f1c 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -58,13 +58,9 @@ abstract class DrillPreparedStatementImpl extends AvaticaPreparedStatement
resultSetType, resultSetConcurrency, resultSetHoldability);
connection.openStatementsRegistry.addStatement(this);
this.preparedStatementHandle = preparedStatementHandle;
- if (preparedStatementHandle != null) {
- ((DrillColumnMetaDataList) signature.columns).updateColumnMetaData(preparedStatementHandle.getColumnsList());
- }
+ ((DrillColumnMetaDataList) signature.columns).updateColumnMetaData(preparedStatementHandle.getColumnsList());
}
-
-
/**
* Throws AlreadyClosedSqlException <i>iff</i> this PreparedStatement is closed.
*
@@ -333,13 +329,17 @@ abstract class DrillPreparedStatementImpl extends AvaticaPreparedStatement
}
@Override
- public void clearBatch() throws SQLException {
- throwIfClosed();
+ public void clearBatch() throws RuntimeException {
+ try {
+ throwIfClosed();
+ } catch (AlreadyClosedSqlException e) {
+ throw new RuntimeException(e);
+ }
try {
super.clearBatch();
}
catch (UnsupportedOperationException e) {
- throw new SQLFeatureNotSupportedException(e.getMessage(), e);
+ throw new RuntimeException(new SQLFeatureNotSupportedException(e.getMessage(), e));
}
}
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 c8b4e3d55..f4fc588c6 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
@@ -1,4 +1,4 @@
-/**
+/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -48,6 +48,7 @@ import org.apache.calcite.avatica.AvaticaSite;
import org.apache.calcite.avatica.AvaticaStatement;
import org.apache.calcite.avatica.ColumnMetaData;
import org.apache.calcite.avatica.Meta;
+import org.apache.calcite.avatica.QueryState;
import org.apache.calcite.avatica.util.Cursor;
import org.apache.calcite.avatica.util.Cursor.Accessor;
import org.apache.drill.jdbc.AlreadyClosedSqlException;
@@ -66,10 +67,10 @@ class DrillResultSetImpl extends AvaticaResultSet implements DrillResultSet {
private final DrillConnectionImpl connection;
private volatile boolean hasPendingCancelationNotification = false;
- DrillResultSetImpl(AvaticaStatement statement, Meta.Signature signature,
+ DrillResultSetImpl(AvaticaStatement statement, QueryState state, Meta.Signature signature,
ResultSetMetaData resultSetMetaData, TimeZone timeZone,
Meta.Frame firstFrame) {
- super(statement, signature, resultSetMetaData, timeZone, firstFrame);
+ super(statement, state, signature, resultSetMetaData, timeZone, firstFrame);
connection = (DrillConnectionImpl) statement.getConnection();
}