You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2015/10/08 01:23:42 UTC
incubator-calcite git commit: [CALCITE-905] getTables returns empty
result in JdbcMeta (Jan Van Besien)
Repository: incubator-calcite
Updated Branches:
refs/heads/master 26f303e83 -> 73e81ac26
[CALCITE-905] getTables returns empty result in JdbcMeta (Jan Van Besien)
Fix instructions for installing protobuf.
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/73e81ac2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/73e81ac2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/73e81ac2
Branch: refs/heads/master
Commit: 73e81ac2608605c4df0792b0df17c93db0ad7a58
Parents: 26f303e
Author: Jan Van Besien <ja...@ngdata.com>
Authored: Fri Oct 2 13:37:52 2015 -0700
Committer: Julian Hyde <jh...@apache.org>
Committed: Wed Oct 7 15:35:45 2015 -0700
----------------------------------------------------------------------
.../apache/calcite/avatica/jdbc/JdbcMeta.java | 2 +-
.../calcite/avatica/RemoteDriverTest.java | 22 ++++
.../apache/calcite/avatica/proto/Common.java | 1 -
.../apache/calcite/avatica/proto/Requests.java | 127 +++++++++++++++----
.../apache/calcite/avatica/proto/Responses.java | 1 -
.../apache/calcite/avatica/remote/Service.java | 12 +-
avatica/src/main/protobuf/requests.proto | 1 +
site/_docs/howto.md | 6 +-
8 files changed, 141 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
----------------------------------------------------------------------
diff --git a/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java b/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
index 83ba087..798fb53 100644
--- a/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
+++ b/avatica-server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
@@ -805,7 +805,7 @@ public class JdbcMeta implements Meta {
private static String[] toArray(List<String> typeList) {
if (typeList == null) {
- return new String[0];
+ return null;
}
return typeList.toArray(new String[typeList.size()]);
}
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
----------------------------------------------------------------------
diff --git a/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java b/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
index 5c0dd2b..7e7b39f 100644
--- a/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
+++ b/avatica-server/src/test/java/org/apache/calcite/avatica/RemoteDriverTest.java
@@ -285,6 +285,28 @@ public class RemoteDriverTest {
}
}
+ @Test public void testGetTables() throws Exception {
+ ConnectionSpec.getDatabaseLock().lock();
+ try {
+ final Connection connection = getLocalConnection();
+ final ResultSet resultSet =
+ connection.getMetaData().getTables(null, "SCOTT", null, null);
+ assertEquals(13, resultSet.getMetaData().getColumnCount());
+ assertTrue(resultSet.next());
+ assertEquals("DEPT", resultSet.getString(3));
+ assertTrue(resultSet.next());
+ assertEquals("EMP", resultSet.getString(3));
+ assertTrue(resultSet.next());
+ assertEquals("BONUS", resultSet.getString(3));
+ assertTrue(resultSet.next());
+ assertEquals("SALGRADE", resultSet.getString(3));
+ resultSet.close();
+ connection.close();
+ } finally {
+ ConnectionSpec.getDatabaseLock().unlock();
+ }
+ }
+
@Ignore
@Test public void testNoFactory() throws Exception {
final Connection connection =
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica/src/main/java/org/apache/calcite/avatica/proto/Common.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/proto/Common.java b/avatica/src/main/java/org/apache/calcite/avatica/proto/Common.java
index 9bd6989..182acbb 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/proto/Common.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/proto/Common.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: common.proto
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java b/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
index f817432..b870894 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/proto/Requests.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: requests.proto
@@ -1270,6 +1269,15 @@ package org.apache.calcite.avatica.proto;
*/
com.google.protobuf.ByteString
getTypeListBytes(int index);
+
+ /**
+ * <code>optional bool has_type_list = 6;</code>
+ *
+ * <pre>
+ * Having an empty type_list is distinct from a null type_list
+ * </pre>
+ */
+ boolean getHasTypeList();
}
/**
* Protobuf type {@code TablesRequest}
@@ -1292,6 +1300,7 @@ package org.apache.calcite.avatica.proto;
schemaPattern_ = "";
tableNamePattern_ = "";
typeList_ = com.google.protobuf.LazyStringArrayList.EMPTY;
+ hasTypeList_ = false;
}
@java.lang.Override
@@ -1346,6 +1355,11 @@ package org.apache.calcite.avatica.proto;
typeList_.add(bs);
break;
}
+ case 48: {
+
+ hasTypeList_ = input.readBool();
+ break;
+ }
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -1525,6 +1539,19 @@ package org.apache.calcite.avatica.proto;
return typeList_.getByteString(index);
}
+ public static final int HAS_TYPE_LIST_FIELD_NUMBER = 6;
+ private boolean hasTypeList_;
+ /**
+ * <code>optional bool has_type_list = 6;</code>
+ *
+ * <pre>
+ * Having an empty type_list is distinct from a null type_list
+ * </pre>
+ */
+ public boolean getHasTypeList() {
+ return hasTypeList_;
+ }
+
private byte memoizedIsInitialized = -1;
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
@@ -1550,6 +1577,9 @@ package org.apache.calcite.avatica.proto;
for (int i = 0; i < typeList_.size(); i++) {
output.writeBytes(4, typeList_.getByteString(i));
}
+ if (hasTypeList_ != false) {
+ output.writeBool(6, hasTypeList_);
+ }
}
private int memoizedSerializedSize = -1;
@@ -1579,6 +1609,10 @@ package org.apache.calcite.avatica.proto;
size += dataSize;
size += 1 * getTypeListList().size();
}
+ if (hasTypeList_ != false) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBoolSize(6, hasTypeList_);
+ }
memoizedSerializedSize = size;
return size;
}
@@ -1698,6 +1732,8 @@ package org.apache.calcite.avatica.proto;
typeList_ = com.google.protobuf.LazyStringArrayList.EMPTY;
bitField0_ = (bitField0_ & ~0x00000008);
+ hasTypeList_ = false;
+
return this;
}
@@ -1730,6 +1766,7 @@ package org.apache.calcite.avatica.proto;
bitField0_ = (bitField0_ & ~0x00000008);
}
result.typeList_ = typeList_;
+ result.hasTypeList_ = hasTypeList_;
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
@@ -1768,6 +1805,9 @@ package org.apache.calcite.avatica.proto;
}
onChanged();
}
+ if (other.getHasTypeList() != false) {
+ setHasTypeList(other.getHasTypeList());
+ }
onChanged();
return this;
}
@@ -2097,6 +2137,44 @@ package org.apache.calcite.avatica.proto;
onChanged();
return this;
}
+
+ private boolean hasTypeList_ ;
+ /**
+ * <code>optional bool has_type_list = 6;</code>
+ *
+ * <pre>
+ * Having an empty type_list is distinct from a null type_list
+ * </pre>
+ */
+ public boolean getHasTypeList() {
+ return hasTypeList_;
+ }
+ /**
+ * <code>optional bool has_type_list = 6;</code>
+ *
+ * <pre>
+ * Having an empty type_list is distinct from a null type_list
+ * </pre>
+ */
+ public Builder setHasTypeList(boolean value) {
+
+ hasTypeList_ = value;
+ onChanged();
+ return this;
+ }
+ /**
+ * <code>optional bool has_type_list = 6;</code>
+ *
+ * <pre>
+ * Having an empty type_list is distinct from a null type_list
+ * </pre>
+ */
+ public Builder clearHasTypeList() {
+
+ hasTypeList_ = false;
+ onChanged();
+ return this;
+ }
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return this;
@@ -8225,30 +8303,31 @@ package org.apache.calcite.avatica.proto;
"\n\016requests.proto\032\014common.proto\"\021\n\017Catalo" +
"gsRequest\"\031\n\027DatabasePropertyRequest\"9\n\016" +
"SchemasRequest\022\017\n\007catalog\030\001 \001(\t\022\026\n\016schem" +
- "a_pattern\030\002 \001(\t\"g\n\rTablesRequest\022\017\n\007cata" +
+ "a_pattern\030\002 \001(\t\"~\n\rTablesRequest\022\017\n\007cata" +
"log\030\001 \001(\t\022\026\n\016schema_pattern\030\002 \001(\t\022\032\n\022tab" +
"le_name_pattern\030\003 \001(\t\022\021\n\ttype_list\030\004 \003(\t" +
- "\"\023\n\021TableTypesRequest\"r\n\016ColumnsRequest\022" +
- "\017\n\007catalog\030\001 \001(\t\022\026\n\016schema_pattern\030\002 \001(\t" +
- "\022\032\n\022table_name_pattern\030\003 \001(\t\022\033\n\023column_n" +
- "ame_pattern\030\004 \001(\t\"\021\n\017TypeInfoRequest\"k\n\030",
- "PrepareAndExecuteRequest\022\025\n\rconnection_i" +
- "d\030\001 \001(\t\022\013\n\003sql\030\002 \001(\t\022\025\n\rmax_row_count\030\003 " +
- "\001(\004\022\024\n\014statement_id\030\004 \001(\r\"K\n\016PrepareRequ" +
- "est\022\025\n\rconnection_id\030\001 \001(\t\022\013\n\003sql\030\002 \001(\t\022" +
- "\025\n\rmax_row_count\030\003 \001(\004\"\255\001\n\014FetchRequest\022" +
- "\025\n\rconnection_id\030\001 \001(\t\022\024\n\014statement_id\030\002" +
- " \001(\r\022\016\n\006offset\030\003 \001(\004\022\033\n\023fetch_max_row_co" +
- "unt\030\004 \001(\r\022%\n\020parameter_values\030\005 \003(\0132\013.Ty" +
- "pedValue\022\034\n\024has_parameter_values\030\006 \001(\010\"/" +
- "\n\026CreateStatementRequest\022\025\n\rconnection_i",
- "d\030\001 \001(\t\"D\n\025CloseStatementRequest\022\025\n\rconn" +
- "ection_id\030\001 \001(\t\022\024\n\014statement_id\030\002 \001(\r\"/\n" +
- "\026CloseConnectionRequest\022\025\n\rconnection_id" +
- "\030\001 \001(\t\"Y\n\025ConnectionSyncRequest\022\025\n\rconne" +
- "ction_id\030\001 \001(\t\022)\n\nconn_props\030\002 \001(\0132\025.Con" +
- "nectionPropertiesB\"\n org.apache.calcite." +
- "avatica.protob\006proto3"
+ "\022\025\n\rhas_type_list\030\006 \001(\010\"\023\n\021TableTypesReq" +
+ "uest\"r\n\016ColumnsRequest\022\017\n\007catalog\030\001 \001(\t\022" +
+ "\026\n\016schema_pattern\030\002 \001(\t\022\032\n\022table_name_pa" +
+ "ttern\030\003 \001(\t\022\033\n\023column_name_pattern\030\004 \001(\t",
+ "\"\021\n\017TypeInfoRequest\"k\n\030PrepareAndExecute" +
+ "Request\022\025\n\rconnection_id\030\001 \001(\t\022\013\n\003sql\030\002 " +
+ "\001(\t\022\025\n\rmax_row_count\030\003 \001(\004\022\024\n\014statement_" +
+ "id\030\004 \001(\r\"K\n\016PrepareRequest\022\025\n\rconnection" +
+ "_id\030\001 \001(\t\022\013\n\003sql\030\002 \001(\t\022\025\n\rmax_row_count\030" +
+ "\003 \001(\004\"\255\001\n\014FetchRequest\022\025\n\rconnection_id\030" +
+ "\001 \001(\t\022\024\n\014statement_id\030\002 \001(\r\022\016\n\006offset\030\003 " +
+ "\001(\004\022\033\n\023fetch_max_row_count\030\004 \001(\r\022%\n\020para" +
+ "meter_values\030\005 \003(\0132\013.TypedValue\022\034\n\024has_p" +
+ "arameter_values\030\006 \001(\010\"/\n\026CreateStatement",
+ "Request\022\025\n\rconnection_id\030\001 \001(\t\"D\n\025CloseS" +
+ "tatementRequest\022\025\n\rconnection_id\030\001 \001(\t\022\024" +
+ "\n\014statement_id\030\002 \001(\r\"/\n\026CloseConnectionR" +
+ "equest\022\025\n\rconnection_id\030\001 \001(\t\"Y\n\025Connect" +
+ "ionSyncRequest\022\025\n\rconnection_id\030\001 \001(\t\022)\n" +
+ "\nconn_props\030\002 \001(\0132\025.ConnectionProperties" +
+ "B\"\n org.apache.calcite.avatica.protob\006pr" +
+ "oto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
@@ -8286,7 +8365,7 @@ package org.apache.calcite.avatica.proto;
internal_static_TablesRequest_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_TablesRequest_descriptor,
- new java.lang.String[] { "Catalog", "SchemaPattern", "TableNamePattern", "TypeList", });
+ new java.lang.String[] { "Catalog", "SchemaPattern", "TableNamePattern", "TypeList", "HasTypeList", });
internal_static_TableTypesRequest_descriptor =
getDescriptor().getMessageTypes().get(4);
internal_static_TableTypesRequest_fieldAccessorTable = new
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java b/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
index c3fb40a..bed750b 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/proto/Responses.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: responses.proto
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java
----------------------------------------------------------------------
diff --git a/avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java b/avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java
index e78aa2e..757032a 100644
--- a/avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java
+++ b/avatica/src/main/java/org/apache/calcite/avatica/remote/Service.java
@@ -333,7 +333,14 @@ public interface Service {
tableNamePattern = msg.getTableNamePattern();
}
- return new TablesRequest(catalog, schemaPattern, tableNamePattern, msg.getTypeListList());
+ // Cannot determine if a value was set for a repeated field. Must use an extra boolean
+ // parameter to distinguish an empty and null typeList.
+ List<String> typeList = null;
+ if (msg.getHasTypeList()) {
+ typeList = msg.getTypeListList();
+ }
+
+ return new TablesRequest(catalog, schemaPattern, tableNamePattern, typeList);
}
@Override Requests.TablesRequest serialize() {
@@ -349,7 +356,10 @@ public interface Service {
builder.setTableNamePattern(tableNamePattern);
}
if (null != typeList) {
+ builder.setHasTypeList(true);
builder.addAllTypeList(typeList);
+ } else {
+ builder.setHasTypeList(false);
}
return builder.build();
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/avatica/src/main/protobuf/requests.proto
----------------------------------------------------------------------
diff --git a/avatica/src/main/protobuf/requests.proto b/avatica/src/main/protobuf/requests.proto
index 1385c93..705200e 100644
--- a/avatica/src/main/protobuf/requests.proto
+++ b/avatica/src/main/protobuf/requests.proto
@@ -43,6 +43,7 @@ message TablesRequest {
string schema_pattern = 2;
string table_name_pattern = 3;
repeated string type_list = 4;
+ bool has_type_list = 6; // Having an empty type_list is distinct from a null type_list
}
// Request for Meta#getTableTypes()
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/73e81ac2/site/_docs/howto.md
----------------------------------------------------------------------
diff --git a/site/_docs/howto.md b/site/_docs/howto.md
index 3bde093..6b7c904 100644
--- a/site/_docs/howto.md
+++ b/site/_docs/howto.md
@@ -394,11 +394,11 @@ objects.
Typically, the code generated by the Protocol Buffers library doesn't
need to be re-generated only every build, only when the schema changes.
-First, install Protobuf 3.0-beta:
+First, install Protobuf 3.0:
{% highlight bash %}
-$ wget https://github.com/google/protobuf/releases/download/v3.0.0-beta-1/protobuf-java-3.0.0-beta-1.tar.gz
-$ tar xf protobuf-java-3.0.0-beta-1.tar.gz && cd protobuf-3.0.0-beta-1
+$ wget https://github.com/google/protobuf/releases/download/v3.0.0-alpha-2/protobuf-java-3.0.0-alpha-2.tar.gz
+$ tar xf protobuf-java-3.0.0-alpha-2.tar.gz && cd protobuf-3.0.0-alpha-2
$ ./configure
$ make
$ sudo make install