Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing a column in the resultset object throws a No Such column labeled error #148

Open
kkrishrao opened this issue Jul 28, 2022 · 2 comments

Comments

@kkrishrao
Copy link

Hello
We have a table in BigQuery with 4 columns
originaleventtime | TIMESTAMP | REQUIRED
operationcontextid | INTEGER | REQUIRED  
identifier | INTEGER | REQUIRED  
region | STRING | NULLABLE

The JDBC URL is
connection = DriverManager.getConnection("jdbc:BQDriver:int-a-fas-pdo/kkdataset?withServiceAccount=true&user=spanner-faspdo-kk@int-a-fas-pdo.iam.gserviceaccount.com&password=c:\FASGITHUB\int-a-fas-pdo-0757cb5e11b8.json");

We execute a select * on this table
PreparedStatement pstmt = connection.prepareStatement("select * from kk1");
ResultSet rest = pstmt.executeQuery();
But the line
Object originaleventtime=rest.getObject("originaleventtime");

throws an error
net.starschema.clouddb.jdbc.BQSQLException: No Such column labeled: originaleventtime
at net.starschema.clouddb.jdbc.BQForwardOnlyResultSet.findColumn(BQForwardOnlyResultSet.java:588)
at net.starschema.clouddb.jdbc.BQForwardOnlyResultSet.getObject(BQForwardOnlyResultSet.java:1170)

The method findColumn(String columnLabel) has the following implementation.
Why does it use getCatalogName() instaed of getColumnName()

int columncount = this.getMetaData().getColumnCount();
for (int i = 1; i <= columncount; i++) {
  if (this.getMetaData().getCatalogName(i).equals(columnLabel)) {
    return i;
  }

}

The getCatalogName returns the value int-a-fas-pdo

@kmsantanu
Copy link

kmsantanu commented Jul 29, 2022

This is the bug in code
if (this.getMetaData().getCatalogName(i).equals(columnLabel)) {
return i;
}
this.getMetaData().getCatalogName(i) -> returns datasetname
should e replace with
if (rest.getMetaData().getColumnName(i).equals(columnLabel)) {
return i;
}
this.getMetaData().getCatalogName(i) replace with rest.getMetaData().getColumnName(i)

@BytesNomad
Copy link

I raise the PR for fix this issue. I met this also. #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants