feat(bigquery-jdbc): support picosecond in PreparedStatement parameters and batching - #14373
feat(bigquery-jdbc): support picosecond in PreparedStatement parameters and batching#14373keshavdandeva wants to merge 3 commits into
PreparedStatement parameters and batching#14373Conversation
…ters and batching
There was a problem hiding this comment.
Code Review
This pull request introduces support for picosecond-precision timestamps in the BigQuery JDBC driver when enableTimestampPicos is enabled. It updates parameter formatting, adds execution validation to prevent using picosecond data with Legacy SQL, and refactors temporal utilities to support configurable fractional second truncation. The reviewer pointed out a potential bug where replacing all occurrences of 'T' with a space in timestamp strings could corrupt timezone names (e.g., "America/Toronto"), and suggested replacing 'T' only at the standard ISO-8601 separator position.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for picosecond timestamp precision in the BigQuery JDBC driver, controlled by the enableTimestampPicos flag. It refactors parameter handling and temporal utilities to dynamically truncate fractional seconds, and adds validation to prevent using picosecond precision with Legacy SQL. Feedback includes suggestions to robustly handle both uppercase and lowercase 'T' separators in ISO 8601 strings, and to add a guard clause against negative precision values in the truncation utility.
b/545231211
This PR adds picosecond timestamp support for
PreparedStatementparameters and batch execution (EnableTimestampPicos=1), refactors statement pre-flight validation, and optimizes temporal string parsing.Changes
BigQueryParameterHandler: SupportedenableTimestampPicosto preserve up to 12 fractional digits without premature microsecond truncation, cleaned up constructors into afinal-field telescoping chain, and deleted the unused 2-argformatValueForQueryParameteroverload.BigQueryPreparedStatement: PropagatedisEnableTimestampPicosacross statement initialization and batch parameter handling (getStandardBatchJobConfiguration).BigQueryStatement: ConvertedgetJobConfiginto a pure configuration builder and extracted statement checks intovalidateExecution().BigQueryTemporalUtility: Consolidated fractional seconds truncation into a single helper (truncateFractionalSeconds) across all temporal parsers.Key Architectural Decisions
1. Legacy SQL Exception & Pre-Flight Validation (
BigQueryStatement)getJobConfig. A configuration builder should not enforce fatal query-blocking logic. Moving it tovalidateExecution()alongsidecheckClosed()ensures we fail fast at statement execution entry—avoiding false "Executing query..." logs and unnecessary OpenTelemetry trace spans.BigQueryJdbcException(generalSQLException) instead ofSQLSyntaxErrorException. The query itself (e.g.,SELECT 1) is syntactically valid; the failure is a driver/session configuration conflict, not a SQL grammar defect.2. ASCII Character Scanning Optimization (
BigQueryTemporalUtility)truncateFractionalSeconds, we replacedCharacter.isDigit(c)with a direct ASCII check (c >= '0' && c <= '9') and cachedstr.length().Character.isDigiteliminates repeated Unicode table lookups and branching in the fractional scanning loop, reducing CPU overhead on hot result-set parsing paths.