From 715eda8cd9e5721d3513d379af4a13612edf2bcf Mon Sep 17 00:00:00 2001 From: Marieke Gueye Date: Tue, 8 Jun 2021 15:21:54 -0700 Subject: [PATCH 1/3] Add geography type --- .../net/starschema/clouddb/jdbc/BQResultSetMetadata.java | 8 ++++++-- .../starschema/clouddb/jdbc/PreparedStatementTests.java | 6 ++++-- src/test/resources/sampleaccount.properties | 3 ++- src/test/resources/vpcaccount.properties | 5 +++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/starschema/clouddb/jdbc/BQResultSetMetadata.java b/src/main/java/net/starschema/clouddb/jdbc/BQResultSetMetadata.java index 759eeaf5..1fa90ea8 100644 --- a/src/main/java/net/starschema/clouddb/jdbc/BQResultSetMetadata.java +++ b/src/main/java/net/starschema/clouddb/jdbc/BQResultSetMetadata.java @@ -211,7 +211,7 @@ public String getColumnMode(int columnIndex) { * TIMESTAMP => java.sql.Types.TIMESTAMP
* ARRAY => unsupported
* STRUCT => java.sql.Types.STRUCT
- * GEOGRAPHY => unsupported
+ * GEOGRAPHY => java.sql.Types.VARCHAR
* * If making changes to this method, please ensure that these types stay 1:1 with the types listed here: * https://cloud.google.com/bigquery/data-types @@ -279,6 +279,10 @@ public int getColumnType(int column) throws SQLException { return Types.NUMERIC; } + if (Columntype.equals("GEOGRAPHY")) { + return Types.VARCHAR; + } + throw new BQSQLException("Unsupported Type: " + Columntype); // May arise if a new data type is added to BigQuery. A new release of the driver would then be needed in order to map it correctly } @@ -315,7 +319,7 @@ public int getPrecision(int column) throws SQLException { if (Columntype.equals("FLOAT")) { return Float.MAX_EXPONENT; - } + } if (Columntype.equals("BOOLEAN")) { return 1; // A boolean is 1 bit length, but it asks for byte, so // 1 diff --git a/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java b/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java index f228db9e..6c62cc1f 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java +++ b/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java @@ -158,7 +158,8 @@ public void ResultSetMetadataFunctionTestTypes() { {"SELECT CAST('2021-04-09T20:24:39' AS DATETIME)", "2021-04-09T20:24:39"}, {"SELECT CAST('1:23:45' AS TIME)", "01:23:45"}, {"SELECT CAST('test' AS BYTES)", "dGVzdA=="}, - {"SELECT CAST('123' as BIGNUMERIC)", "123"} + {"SELECT CAST('123' as BIGNUMERIC)", "123"}, + {"SELECT ST_GEOGFROMTEXT('LINESTRING(6.2312655 51.9967517, 6.2312606 51.9968043)')", "LINESTRING(6.2312655 51.9967517, 6.2312606 51.9968043)"} }; final int[] expectedType = new int[]{ @@ -172,7 +173,8 @@ public void ResultSetMetadataFunctionTestTypes() { java.sql.Types.TIMESTAMP, java.sql.Types.TIME, java.sql.Types.VARCHAR, - java.sql.Types.NUMERIC + java.sql.Types.NUMERIC, + java.sql.Types.VARCHAR }; for (int i = 0; i < queries.length; i ++) { diff --git a/src/test/resources/sampleaccount.properties b/src/test/resources/sampleaccount.properties index 353153cc..0d6e2510 100644 --- a/src/test/resources/sampleaccount.properties +++ b/src/test/resources/sampleaccount.properties @@ -1,4 +1,5 @@ projectid=super-party-888 type=service user=697117590302-76cr6q3217nck6gks0kf4r151j4d9f8e@developer.gserviceaccount.com -password=src/test/resources/credentials_go_here.p12 \ No newline at end of file +password=src/test/resources/credentials_go_here.p12 +transformquery=true diff --git a/src/test/resources/vpcaccount.properties b/src/test/resources/vpcaccount.properties index faa4f83e..bc561645 100644 --- a/src/test/resources/vpcaccount.properties +++ b/src/test/resources/vpcaccount.properties @@ -1,6 +1,7 @@ -projectid=super-party-888 +projectid=disco-parsec-659 type=service user=697117590302-76cr6q3217nck6gks0kf4r151j4d9f8e@developer.gserviceaccount.com -password=src/test/resources/bigquery_credentials.p12 dataset=looker_test +password=src/test/resources/bigquery_credentials.p12 transformquery=true +rootUrl=https://restricted.googleapis.com From 54401f7594a7599a138cfb9dbfc1b089bb942f5a Mon Sep 17 00:00:00 2001 From: Marieke Gueye Date: Tue, 8 Jun 2021 16:16:48 -0700 Subject: [PATCH 2/3] rollback proparties --- src/test/resources/sampleaccount.properties | 1 - src/test/resources/vpcaccount.properties | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/test/resources/sampleaccount.properties b/src/test/resources/sampleaccount.properties index 0d6e2510..a8037475 100644 --- a/src/test/resources/sampleaccount.properties +++ b/src/test/resources/sampleaccount.properties @@ -2,4 +2,3 @@ projectid=super-party-888 type=service user=697117590302-76cr6q3217nck6gks0kf4r151j4d9f8e@developer.gserviceaccount.com password=src/test/resources/credentials_go_here.p12 -transformquery=true diff --git a/src/test/resources/vpcaccount.properties b/src/test/resources/vpcaccount.properties index bc561645..faa4f83e 100644 --- a/src/test/resources/vpcaccount.properties +++ b/src/test/resources/vpcaccount.properties @@ -1,7 +1,6 @@ -projectid=disco-parsec-659 +projectid=super-party-888 type=service user=697117590302-76cr6q3217nck6gks0kf4r151j4d9f8e@developer.gserviceaccount.com -dataset=looker_test password=src/test/resources/bigquery_credentials.p12 +dataset=looker_test transformquery=true -rootUrl=https://restricted.googleapis.com From 1e2ff14c35aa845ad38ddf4b913258f531d31ceb Mon Sep 17 00:00:00 2001 From: Marieke Gueye Date: Tue, 8 Jun 2021 16:56:46 -0700 Subject: [PATCH 3/3] change version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 66706eab..ecb1dc1c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ to a groupId that we have ownership over --> com.github.jonathanswenson bqjdbc - 2.3.6-SNAPSHOT + 2.3.6 Big Query over JDBC A simple JDBC driver, to reach Google's BigQuery