Skip to content

Commit d08691a

Browse files
authored
fix(bqjdbc): update metadata values for GEOGRAPHY/JSON/INTERVAL types (#13223)
1 parent b1279ab commit d08691a

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaData.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4855,9 +4855,11 @@ private ColumnTypeInfo getColumnTypeInfoForSqlType(StandardSQLTypeName bqType) {
48554855
case TIME:
48564856
return new ColumnTypeInfo(Types.TIME, "TIME", 15, null, null);
48574857
case GEOGRAPHY:
4858+
return new ColumnTypeInfo(Types.OTHER, "GEOGRAPHY", null, null, null);
48584859
case JSON:
4860+
return new ColumnTypeInfo(Types.OTHER, "JSON", null, null, null);
48594861
case INTERVAL:
4860-
return new ColumnTypeInfo(Types.VARCHAR, "VARCHAR", null, null, null);
4862+
return new ColumnTypeInfo(Types.OTHER, "INTERVAL", null, null, null);
48614863
case BYTES:
48624864
return new ColumnTypeInfo(Types.VARBINARY, "VARBINARY", null, null, null);
48634865
case STRUCT:

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryDatabaseMetaDataTest.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,37 @@ public void testMapBigQueryTypeToJdbc_ScalarTypes() {
342342
assertEquals(Integer.valueOf(38), infoBigNumeric.decimalDigits);
343343
assertEquals(Integer.valueOf(10), infoBigNumeric.numPrecRadix);
344344

345-
// GEOGRAPHY -> VARCHAR
345+
// GEOGRAPHY -> OTHER
346346
Field fieldGeo =
347347
Field.newBuilder("test_geo", StandardSQLTypeName.GEOGRAPHY)
348348
.setMode(Field.Mode.NULLABLE)
349349
.build();
350350
BigQueryDatabaseMetaData.ColumnTypeInfo infoGeo = dbMetadata.mapBigQueryTypeToJdbc(fieldGeo);
351-
assertEquals(Types.VARCHAR, infoGeo.jdbcType);
352-
assertEquals("VARCHAR", infoGeo.typeName);
351+
assertEquals(Types.OTHER, infoGeo.jdbcType);
352+
assertEquals("GEOGRAPHY", infoGeo.typeName);
353353
assertNull(infoGeo.columnSize);
354354

355+
// JSON -> OTHER
356+
Field fieldJson =
357+
Field.newBuilder("test_json", StandardSQLTypeName.JSON)
358+
.setMode(Field.Mode.NULLABLE)
359+
.build();
360+
BigQueryDatabaseMetaData.ColumnTypeInfo infoJson = dbMetadata.mapBigQueryTypeToJdbc(fieldJson);
361+
assertEquals(Types.OTHER, infoJson.jdbcType);
362+
assertEquals("JSON", infoJson.typeName);
363+
assertNull(infoJson.columnSize);
364+
365+
// INTERVAL -> OTHER
366+
Field fieldInterval =
367+
Field.newBuilder("test_interval", StandardSQLTypeName.INTERVAL)
368+
.setMode(Field.Mode.NULLABLE)
369+
.build();
370+
BigQueryDatabaseMetaData.ColumnTypeInfo infoInterval =
371+
dbMetadata.mapBigQueryTypeToJdbc(fieldInterval);
372+
assertEquals(Types.OTHER, infoInterval.jdbcType);
373+
assertEquals("INTERVAL", infoInterval.typeName);
374+
assertNull(infoInterval.columnSize);
375+
355376
// DATE
356377
Field fieldDate =
357378
Field.newBuilder("test_date", StandardSQLTypeName.DATE)

0 commit comments

Comments
 (0)