Skip to content

Add DateTime wrapper type for DATETIME round-trip support#6

Open
junyahondarubrik wants to merge 1 commit intomasterfrom
datetime-wrapper-type
Open

Add DateTime wrapper type for DATETIME round-trip support#6
junyahondarubrik wants to merge 1 commit intomasterfrom
datetime-wrapper-type

Conversation

@junyahondarubrik
Copy link
Collaborator

@junyahondarubrik junyahondarubrik commented Mar 3, 2026

Summary

  • Adds a DateTime wrapper type in driver/columns.go that embeds time.Time to preserve BigQuery DATETIME (timezone-naive) semantics
  • ConvertValue now returns DateTime instead of raw time.Time for DATETIME columns
  • buildParameter and buildParameterFromNamedValue in statement.go intercept DateTime and convert it back to civil.DateTime, ensuring BigQuery maps the parameter to DATETIME (not TIMESTAMP)
  • DateTime implements driver.Valuer returning time.Time, so database/sql.Scan transparently assigns it to *time.Time targets — no consumer changes needed

Problem

The BigQuery Go client always maps time.Time to TIMESTAMP when used as a query parameter. This causes a type mismatch when DATETIME values read from BigQuery are used in subsequent parameterized queries (e.g., MERGE statements with partition filtering).

Test Plan

  • Added driver/columns_test.go: tests for DateTime.Value(), ConvertValue returning DateTime for DATETIME columns, DATE and TIME column handling, compile-time driver.Valuer check
  • Added driver/statement_test.go: tests for buildParameter converting DateTime to civil.DateTime, named/unnamed parameter paths, accumulation behavior
  • Copied the driver changes into sdmain's vendor copy (polaris/src/rubrik/vendor/github.com/scaledata/bigquery/driver/) and verified that the downstream consumer (OLAP delta table merge korg job) builds and passes all tests with the new DateTime type

All 20 driver subtests pass. sdmain consumer tests pass via bazel test //rubrik/turing/taskchains/olap-delta-table-merge/merge-tables:go_default_test.

JIRA Issues

SPARK-717719

The BigQuery Go client maps time.Time to TIMESTAMP when used as a
query parameter. This causes a type mismatch when DATETIME values
read from BigQuery are passed back as parameters in subsequent
queries (e.g., MERGE partition filtering).

Introduce a DateTime wrapper type that:
- Embeds time.Time for transparent consumer compatibility
- Implements driver.Valuer returning time.Time for sql.Scan
- Gets intercepted in buildParameter to convert back to
  civil.DateTime, ensuring BigQuery maps it to DATETIME

JIRA: SPARK-717719
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant