Skip to content

[WIP] test(bigquery-jdbc): add 17-type REST vs ProtoSchema parity and SQL-fallback regression suites - #15188

Open
Neenu1995 wants to merge 1 commit into
fix/swa-v2-5-schema-session-gatingfrom
fix/swa-v2-6-parity-regression-tests
Open

Neenu1995 wants to merge 1 commit into
fix/swa-v2-5-schema-session-gatingfrom
fix/swa-v2-6-parity-regression-tests

Conversation

@Neenu1995

Copy link
Copy Markdown
Contributor

Stack: PR 6 of 6 (base: fix/swa-v2-5-schema-session-gating)
Bug: b/587228731, b/587340667, b/419328655

Summary

Add end-to-end 17-type Storage Write API (ProtoSchema) vs. Standard SQL DML (QueryParameterValue) parity and SQL-fallback regression suites across unit (in-process gRPC) and live BigQuery integration (ITNightlyBigQueryTest) tests.

Design Decisions

  • Cross-Pathway Wire Parity Over Legacy Bug Preservation (b/587340667, b/419328655): Assert that ProtoRows payloads streamed through an in-process BigQueryWriteGrpc server match BigQueryParameterHandler.toQueryParameterValue across all supported scalar types (including TIMESTAMP(12), 1582-10-10 Gregorian cutover DATE, 2025-03-09T02:30:00 DST-gap DATETIME, pre-1970 sub-microsecond TIMESTAMP, nanosecond truncation, Float binary widening, trailing-zero & 0E+50 BigDecimals, `col-é`, and C_INT) under US/FRANCE/JAPAN/tr-TR locales, 4 timezones, and EnableTimestampPicos=false/true.
  • Live Round-Trip & Log-Verified Path Assertions (b/587228731): Insert identical batches into live BigQuery tables with EnableWriteAPI=1 and EnableWriteAPI=0 in ITNightlyBigQueryTest, verifying execution path via driver logs and cell-by-cell ResultSet equality across 16 columns, NULLs, reordered column lists, SQL expressions/UDFs, and ARRAY/STRUCT/RANGE fallbacks.

…allback regression suites

Stack: PR 6 of 6 (base: `fix/swa-v2-5-schema-session-gating`)

### Summary
- Add an in-process gRPC `StreamWriter` + `ProtoSchema` parity test in `BigQueryPreparedStatementWriteApiTest` verifying exact value parity against `BigQueryParameterHandler.toQueryParameterValue` across both non-null rows and all supported `StandardSQLTypeName`s (including `TIMESTAMP(12)`, `1582-10-10` Gregorian cutover `DATE`, `2025-03-09T02:30:00` DST-gap `DATETIME`, pre-1970 sub-microsecond `TIMESTAMP`, nanosecond `TIME`/`DATETIME` truncation, `Float` binary widening, trailing-zero & `0E+50` `BigDecimal`s, non-ASCII column `` `col-é` ``, and uppercase `'I'` column `C_INT`) across `US`/`FRANCE`/`JAPAN`/`tr-TR` locales, `UTC`/`America/New_York`/`Asia/Tokyo`/`Europe/Istanbul` timezones, and `EnableTimestampPicos=false/true`.
- Add live BigQuery integration tests in `ITNightlyBigQueryTest` verifying cell-by-cell ResultSet parity (and asserting Storage Write API vs. standard SQL execution path via driver logs) across 16 columns, `NULL` rows, and reordered column lists, plus automatic SQL DML fallback for SQL expressions (`UPPER(?)`, `SHA256(?)`, `ST_GEOGFROMTEXT(?)`, `MAKE_INTERVAL(...)`, `PARSE_JSON(?)`) and `ARRAY`/`STRUCT`/`RANGE` tables.

### Testing
- `make lint`, `mvn -B -ntp verify -DskipTests -DskipITs`, `mvn -B -ntp dependency:analyze -Pquick-build -DfailOnWarning=true -Dmdep.analyze.skip=false`, `mvn -q -Denforcer.skip=true -Dclirr.skip=true test-compile`, and full `make unittest` (live execution of `ITNightlyBigQueryTest` requires `GOOGLE_APPLICATION_CREDENTIALS` in CI).
@Neenu1995
Neenu1995 requested review from a team as code owners November 24, 2026 01:42

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive unit and integration tests to verify the BigQuery Write API's behavior, specifically testing schema and type parity across various locales, time zones, and configurations, as well as fallback mechanisms for SQL expressions and complex types. The review feedback highlights potential concurrency issues in these tests due to the modification of JVM-wide and global states (such as default locales, time zones, and root logger configurations). To prevent flaky tests, the reviewer recommends using JUnit 5's @ResourceLock annotations to ensure isolated execution.

Comment on lines +808 to +810
@Test
public void testAllSupportedTypesEndToEndProtoSchemaParityAcrossLocalesZonesAndPicos()
throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Modifying the JVM-wide default locale and timezone (Locale.setDefault and TimeZone.setDefault) inside a test can cause flaky tests and race conditions if other tests are executed concurrently in the same JVM. To prevent this, use JUnit 5's @ResourceLock annotations to ensure this test runs in isolation when parallel execution is enabled.

  @Test
  @org.junit.jupiter.api.parallel.ResourceLock(org.junit.jupiter.api.parallel.Resources.LOCALE)
  @org.junit.jupiter.api.parallel.ResourceLock(org.junit.jupiter.api.parallel.Resources.TIME_ZONE)
  public void testAllSupportedTypesEndToEndProtoSchemaParityAcrossLocalesZonesAndPicos()
      throws Exception {

Comment on lines +1415 to +1416
@Test
public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The helper method executeBatchAssertingWriteApiUsed modifies the global rootLogger level and handlers. If multiple tests calling this helper run concurrently, they will interfere with each other's logging assertions and logger state. Use a custom @ResourceLock to prevent concurrent execution of these tests.

Suggested change
@Test
public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException {
@Test
@org.junit.jupiter.api.parallel.ResourceLock("BigQueryDriverLogger")
public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException {

Comment on lines +1495 to +1496
@Test
public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The helper method executeBatchAssertingWriteApiUsed modifies the global rootLogger level and handlers. Use a custom @ResourceLock to prevent concurrent execution with other tests that modify the same logger.

Suggested change
@Test
public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException {
@Test
@org.junit.jupiter.api.parallel.ResourceLock("BigQueryDriverLogger")
public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException {

This branch has not been deployed

No deployments
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