Skip to content

Commit ccd13eb

Browse files
authored
feat(bigquery-jdbc): standardize parameter handling and calendar defensive copying across statement interfaces (#13805)
b/535194644 * **Hardened CallableStatement Getters**: Replaced reversed `isAssignableFrom` checks with `instanceof`, `Number`/`Date` coercions, and direct delegation to `getObject()`. * **Standardized JDBC Parameter Names**: Updated synthetic parameter names (`arg0`, `arg1`) to standard JDBC names (`parameterIndex`, `parameterName`, `scale`). * **Symmetrical Timezone Coercion**: Centralized `Calendar` timezone conversions using `java.time` APIs across statements and result sets. * **ParameterMetaData & Dynamic Modes**: Added support for dynamic `IN`, `OUT`, and `INOUT` parameter modes in `BigQueryParameterMetaData`. * **PreparedStatement Hardening**: Added defensive copying for `Calendar` setters and replaced silent stubs with explicit unsupported feature exceptions.
1 parent bc19822 commit ccd13eb

3 files changed

Lines changed: 547 additions & 636 deletions

File tree

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

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -544,33 +544,21 @@ public InputStream getBinaryStream(int columnIndex) throws SQLException {
544544
public Date getDate(int columnIndex, Calendar cal) throws SQLException {
545545
LOG.finestTrace("getDate");
546546
Date date = getDate(columnIndex);
547-
if (date == null || cal == null) {
548-
return null;
549-
}
550-
cal.setTimeInMillis(date.getTime());
551-
return new java.sql.Date(cal.getTimeInMillis());
547+
return BigQueryTypeCoercionUtility.convertDateWithCalendar(date, cal);
552548
}
553549

554550
@Override
555551
public Time getTime(int columnIndex, Calendar cal) throws SQLException {
556552
LOG.finestTrace("getTime");
557553
Time time = getTime(columnIndex);
558-
if (time == null || cal == null) {
559-
return null;
560-
}
561-
cal.setTimeInMillis(time.getTime());
562-
return new java.sql.Time(cal.getTimeInMillis());
554+
return BigQueryTypeCoercionUtility.convertTimeWithCalendar(time, cal);
563555
}
564556

565557
@Override
566558
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException {
567559
LOG.finestTrace("getTimestamp");
568-
Timestamp timeStamp = getTimestamp(columnIndex);
569-
if (timeStamp == null || cal == null) {
570-
return null;
571-
}
572-
cal.setTimeInMillis(timeStamp.getTime());
573-
return new java.sql.Timestamp(cal.getTimeInMillis());
560+
Timestamp timestamp = getTimestamp(columnIndex);
561+
return BigQueryTypeCoercionUtility.convertTimestampWithCalendar(timestamp, cal);
574562
}
575563

576564
@Override

0 commit comments

Comments
 (0)