Skip to content

Commit 59b66fb

Browse files
Yuri Oliveclaude
andcommitted
refactor(jdbc): simplify BigQuery driver detection and rename timestamp helper
Remove redundant `googlebigquery` check — `bigquery` substring already matches both driver class variants. Rename `convertPostgresTimestampWithTimezoneValue` to `convertTimestampWithTimezoneValue` to reflect its shared use by both PostgreSQL and BigQuery timestamp conversion paths. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 966a920 commit 59b66fb

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

fe/fe-core/src/main/java/com/starrocks/connector/jdbc/JDBCMetadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private JDBCSchemaResolver createSchemaResolver() {
137137
return new OracleSchemaResolver(properties);
138138
} else if (driverClass.contains("sqlserver")) {
139139
return new SqlServerSchemaResolver();
140-
} else if (driverClass.contains("bigquery") || driverClass.contains("googlebigquery")) {
140+
} else if (driverClass.contains("bigquery")) {
141141
return new BigQuerySchemaResolver();
142142
} else {
143143
LOG.warn("{} not support yet", properties.get(JDBCResource.DRIVER_CLASS));

java-extensions/jdbc-bridge/src/main/java/com/starrocks/jdbcbridge/JDBCScanner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public JDBCScanner(String driverLocation, JDBCScanContext scanContext) {
8282
this.isOracleDriver = scanContext.getDriverClassName().toLowerCase(Locale.ROOT).contains("oracle");
8383
this.isPostgresDriver = scanContext.getDriverClassName().toLowerCase(Locale.ROOT).contains("postgresql");
8484
String driverClassLower = scanContext.getDriverClassName().toLowerCase(Locale.ROOT);
85-
this.isBigQueryDriver = driverClassLower.contains("bigquery") || driverClassLower.contains("googlebigquery");
85+
this.isBigQueryDriver = driverClassLower.contains("bigquery");
8686
this.queryTimeZone = resolveQueryTimeZone(scanContext.getQueryTimeZone());
8787
}
8888

@@ -313,12 +313,12 @@ public List<Object[]> getNextChunk() throws Exception {
313313
if (shouldConvertPostgresTimestampWithTimezoneColumn(i)) {
314314
Timestamp timestampValue =
315315
resultObject instanceof Timestamp ? (Timestamp) resultObject : resultSet.getTimestamp(i + 1);
316-
dataColumn[resultNumRows] = convertPostgresTimestampWithTimezoneValue(timestampValue);
316+
dataColumn[resultNumRows] = convertTimestampWithTimezoneValue(timestampValue);
317317
} else if (shouldConvertBigQueryTimestampColumn(i)) {
318318
Timestamp timestampValue =
319319
resultObject instanceof Timestamp ? (Timestamp) resultObject : resultSet.getTimestamp(i + 1);
320320
// BigQuery TIMESTAMP is UTC; reuse the same UTC→queryTZ adjustment.
321-
dataColumn[resultNumRows] = convertPostgresTimestampWithTimezoneValue(timestampValue);
321+
dataColumn[resultNumRows] = convertTimestampWithTimezoneValue(timestampValue);
322322
} else {
323323
dataColumn[resultNumRows] = resultObject;
324324
}
@@ -452,14 +452,14 @@ private Time convertPostgresTimeWithTimezoneValue(Time sourceValue) {
452452
return new Time(sourceMillis + computeTimezoneOffsetMillis(sourceMillis));
453453
}
454454

455-
private Timestamp convertPostgresTimestampWithTimezoneValue(Timestamp sourceValue) {
455+
private Timestamp convertTimestampWithTimezoneValue(Timestamp sourceValue) {
456456
if (sourceValue == null || queryTimeZone == null) {
457457
return sourceValue;
458458
}
459459
// Avoid Timestamp.toInstant() as it uses the proleptic Gregorian calendar,
460460
// while java.sql.Timestamp uses the Julian calendar for dates before October 15, 1582.
461461
// This calendar mismatch causes incorrect date conversion for very old dates (e.g., year 0001).
462-
// Instead, adjust via epoch millis like convertPostgresTimeWithTimezoneValue does.
462+
// Instead, adjust via epoch millis like convertTimeWithTimezoneValue does.
463463
long sourceMillis = sourceValue.getTime();
464464
int nanos = sourceValue.getNanos();
465465
Timestamp result = new Timestamp(sourceMillis + computeTimezoneOffsetMillis(sourceMillis));

0 commit comments

Comments
 (0)