You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7dd2b37
Browse filesBrowse the repository at this point in the historyBrowse files
fix(bigquery-jdbc): honor Calendar timezone and prevent ClassCastException in ResultSet temporal getters (#14657)
b/565791346
### Summary
Fixes two bugs in `ResultSet.getDate(col, Calendar)`,
`ResultSet.getTime(col, Calendar)`, and `ResultSet.getTimestamp(col,
Calendar)`:
1. **`Calendar` ignored on `DATE`, `TIME`, and `DATETIME` columns:**
- Previously, the `Calendar` getter overloads called
`getObject(columnIndex)` first with `zone = null`, which boxed raw
values into `Date`, `Time`, or `Timestamp` anchored in the JVM default
timezone before `BigQueryTypeRegistry.convert(..., zone)` ran.
- Arrow `DATE` (`LocalDate` / `Integer`) and `DATETIME`
(`LocalDateTime`) branches in `BigQueryTypeRegistry` also used
`Date.valueOf(...)` and `Timestamp.valueOf(...)`, ignoring `zone`.
2. **`ClassCastException` on cross-type conversions (e.g., `getDate` /
`getTime` on `DATETIME` or `TIMESTAMP` columns):**
- `BigQueryTypeRegistry.convert(input, bqType, targetClass, zoneId)`
dispatched solely by `bqType`, returning a `Timestamp` for `DATETIME`
and `TIMESTAMP` columns even when `targetClass` was `Date.class` or
`Time.class`.
### Changes
- Added `getObject(int columnIndex, ZoneId zone)` to
`BigQueryBaseResultSet`, `BigQueryJsonResultSet`, and
`BigQueryArrowResultSet` so the `Calendar`'s `ZoneId` is applied during
initial unboxing for zone-less types (`DATE`, `TIME`, `DATETIME`), while
continuing to ignore `Calendar` on `TIMESTAMP` columns per the JDBC
specification.
- Overloaded `boxDate(LocalDate, ZoneId)`, `boxDateTime(LocalDateTime,
ZoneId)`, and `boxTime(LocalTime, ZoneId)` in `BigQueryTemporalUtility`
and wired them into `BigQueryTypeRegistry`.
- Updated `BigQueryTypeRegistry.convert(Object, StandardSQLTypeName,
Class<T>, ZoneId)` to delegate to the target class descriptor when the
column descriptor returns an intermediate type.
- Added unit tests in `BigQueryJsonResultSetTest`,
`BigQueryArrowResultSetTest`, and `BigQueryTypeRegistryTest`.
0 commit comments