Skip to content

Commit

Permalink
Merge pull request #91 from jonathanswenson/add_geography_type
Browse files Browse the repository at this point in the history
Support geography type
  • Loading branch information
mkou authored Jun 9, 2021
2 parents 4d0fd1e + 1e2ff14 commit adc1dfc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
to a groupId that we have ownership over -->
<groupId>com.github.jonathanswenson</groupId>
<artifactId>bqjdbc</artifactId>
<version>2.3.6-SNAPSHOT</version>
<version>2.3.6</version>
<name>Big Query over JDBC</name>
<description>A simple JDBC driver, to reach Google's BigQuery</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public String getColumnMode(int columnIndex) {
* TIMESTAMP => java.sql.Types.TIMESTAMP<br>
* ARRAY => unsupported<br>
* STRUCT => java.sql.Types.STRUCT<br>
* GEOGRAPHY => unsupported<br>
* GEOGRAPHY => java.sql.Types.VARCHAR<br>
*
* 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
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]{
Expand All @@ -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 ++) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/sampleaccount.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
projectid=super-party-888
type=service
user=697117590302-76cr6q3217nck6gks0kf4r151j4d9f8e@developer.gserviceaccount.com
password=src/test/resources/credentials_go_here.p12
password=src/test/resources/credentials_go_here.p12

0 comments on commit adc1dfc

Please sign in to comment.