Slemma / BigQuery-jdbc-driver

Automatically exported from code.google.com/p/starschema-bigquery-jdbc
1 stars 0 forks source link

BigQuery Integer is bigger than a Java Integer. #10

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Integer field with a number greater than 2^21. In my example: 45295810863

What is the expected output? What do you see instead?

Expect to correct value in result set, but instead it throws...

Error retrieving results: net.starschema.clouddb.jdbc.BQSQLException: 
java.lang.NumberFormatException: For input string: "45295810863"
net.starschema.clouddb.jdbc.BQSQLException: java.lang.NumberFormatException: 
For input string: "45295810863"
    at net.starschema.clouddb.jdbc.BQForwardOnlyResultSet.getObject(BQForwardOnlyResultSet.java:177)

What version of the product are you using? On what operating system?

Starschema Driver 1.4, JRE 1.7.0_45, Mint Linux

Please provide any additional information below.

Not sure what you can do about this other than converting to a Long or 
incompatible values to nulls.

Original issue reported on code.google.com by supp...@yellowfin.com.au on 26 Jun 2014 at 2:21

GoogleCodeExporter commented 9 years ago
According to the BigQuery documentation, BigQuery's INTEGER have 64 bits.
Link: https://cloud.google.com/bigquery/preparing-data-for-bigquery#datatypes

According to the Java.Sql documentation, following types are available:
INTEGER - 32 bits
BIGINT - 64 bits
Source (look for "BIGINT" in the page) : 
http://download.java.net/jdk7/archive/b125/docs/technotes/guides/jdbc/getstart/m
apping.html

So the resultSetMetaData has to return BIGINT.

A fix is available on my fork but I do not know how to integrate it to the 
official repository.

Fix:
https://github.com/jsiessataccess/starschema-bigquery-jdbc/commit/1de2efb8dbbf59
041692ef92788f5d1de9c72ae0

If you do not use the meta data, then directly use getLong(...) as long have 64 
bits.

Original comment by Johann.S...@theaccessgroup.fr on 2 Apr 2015 at 9:35