Repository navigation
[WIP] test(bigquery-jdbc): add 17-type REST vs ProtoSchema parity and SQL-fallback regression suites - #15188
Conversation
…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).
There was a problem hiding this comment.
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.
| @Test | ||
| public void testAllSupportedTypesEndToEndProtoSchemaParityAcrossLocalesZonesAndPicos() | ||
| throws Exception { |
There was a problem hiding this comment.
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 {| @Test | ||
| public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException { |
There was a problem hiding this comment.
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.
| @Test | |
| public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException { | |
| @Test | |
| @org.junit.jupiter.api.parallel.ResourceLock("BigQueryDriverLogger") | |
| public void testBulkInsertWriteApiAllTypesParityWithStandardSql() throws SQLException { |
| @Test | ||
| public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException { |
There was a problem hiding this comment.
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.
| @Test | |
| public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException { | |
| @Test | |
| @org.junit.jupiter.api.parallel.ResourceLock("BigQueryDriverLogger") | |
| public void testBulkInsertWriteApiSqlExpressionAndComplexTypeFallback() throws SQLException { |
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
b/587340667,b/419328655): Assert thatProtoRowspayloads streamed through an in-processBigQueryWriteGrpcserver matchBigQueryParameterHandler.toQueryParameterValueacross all supported scalar types (includingTIMESTAMP(12),1582-10-10Gregorian cutoverDATE,2025-03-09T02:30:00DST-gapDATETIME, pre-1970 sub-microsecondTIMESTAMP, nanosecond truncation,Floatbinary widening, trailing-zero &0E+50BigDecimals,`col-é`, andC_INT) underUS/FRANCE/JAPAN/tr-TRlocales, 4 timezones, andEnableTimestampPicos=false/true.b/587228731): Insert identical batches into live BigQuery tables withEnableWriteAPI=1andEnableWriteAPI=0inITNightlyBigQueryTest, verifying execution path via driver logs and cell-by-cellResultSetequality across 16 columns,NULLs, reordered column lists, SQL expressions/UDFs, andARRAY/STRUCT/RANGEfallbacks.