Skip to content

test(bigquery-jdbc): update tests to run in TPC - #14014

Draft
logachev wants to merge 2 commits into
mainfrom
kirl/tpc_tests
Draft

test(bigquery-jdbc): update tests to run in TPC#14014
logachev wants to merge 2 commits into
mainfrom
kirl/tpc_tests

Conversation

@logachev

@logachev logachev commented Aug 8, 2026

Copy link
Copy Markdown
Contributor
  • Update all tests queries to use 'GENERATE_ARRAY' instead of public datasets. There are two reasons:
    1. Running these queries in EU region or in TPC will fail
    2. We saw in the past public dataset was moved and we had to adjust it
    3. We're not validating actual queries, so underlying data should be irrelevant
  • Update some tests to use escape characters for table names due to TPC projects following : format and : is not allowed in SQL
  • Mark a lot of tests as disabled in tpc. Will review them 1 by 1 & re-enable, keeping this PR a little shorter.

@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 refactors integration tests in the BigQuery JDBC driver by replacing public dataset queries with dynamically generated data using UNNEST(GENERATE_ARRAY(...)) and introducing a centralized validateStatement helper. While this reduces external dependencies, several critical issues were identified in the review. Specifically, converting queries to Standard SQL in tests configured for Legacy SQL (BIG_QUERY dialect) will cause syntax errors, and removing table references in location-restriction tests will prevent expected exceptions from being thrown. Additionally, an unaliased column in testSmallSelectAndVerifyResults may lead to result retrieval failures.

Comment on lines 394 to +395
BigQueryJdbcException ex =
assertThrows(BigQueryJdbcException.class, () -> statement.executeQuery(query));
assertThrows(BigQueryJdbcException.class, () -> ITBase.validateStatement(statement, 180));

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.

high

In testIncorrectLocation, the test expects a BigQueryJdbcException to be thrown due to a location mismatch (connecting to europe-west3 but querying a US dataset).

However, the query has been changed to ITBase.validateStatement(statement, 180), which executes SELECT * FROM UNNEST(GENERATE_ARRAY(1, 180)). Since this query does not reference any tables, it does not have a location restriction and will execute successfully in europe-west3 without throwing any exception. This will cause the test to fail.

To fix this, you should revert to a query that references a table in a different region (such as the US). Since this test is already tagged with @Tag("disable_tpc"), it is safe to keep the original query referencing the public dataset.

References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

String connection_uri = ITNightlyBigQueryTest.connection_uri;
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;";
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 20000000))";

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.

high

In testNonEnabledUseLegacySQLThrowsSyntaxError, the test expects a syntax error because it attempts to run a Legacy SQL query when Legacy SQL is not enabled.

By changing the query to "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 20000000))", which is valid Standard SQL, the query will execute successfully (or fail due to other reasons like resource limits, but not a syntax error). This will cause the test to fail.

You should revert this query to the original Legacy SQL query using square brackets.

Suggested change
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 20000000))";
String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 20000000;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

Comment on lines 2172 to +2177
String legacyJoinQuery =
"SELECT\n"
+ " repo_name\n"
+ "FROM\n"
+ " [bigquery-public-data.github_repos.commits],\n"
+ " [bigquery-public-data.github_repos.sample_commits] LIMIT 10";
+ "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))"
+ "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))";

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.

high

The updated query in testValidLegacySQLStatement is syntactically invalid in any SQL dialect:

SELECT
  repo_name
FROM
SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))

Additionally, this test is configured with QueryDialect=BIG_QUERY (Legacy SQL), but the new query uses Standard SQL constructs (UNNEST, GENERATE_ARRAY). This will fail with a syntax error, causing the test to fail.

Since this test is already tagged with @Tag("disable_tpc"), you should revert it to the original valid Legacy SQL query.

Suggested change
String legacyJoinQuery =
"SELECT\n"
+ " repo_name\n"
+ "FROM\n"
+ " [bigquery-public-data.github_repos.commits],\n"
+ " [bigquery-public-data.github_repos.sample_commits] LIMIT 10";
+ "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))"
+ "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 10))";
String legacyJoinQuery =
"SELECT\n"
+ " repo_name\n"
+ "FROM\n"
+ " [bigquery-public-data.github_repos.commits],\n"
+ " [bigquery-public-data.github_repos.sample_commits] LIMIT 10";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

+ "LargeResultDataset=INTEGRATION_TESTS;";
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200;";
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))";

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.

high

In testValidDestinationTableSavesQueriesWithLegacySQL, the connection is configured with QueryDialect=BIG_QUERY (Legacy SQL), but the query has been changed to "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))", which is Standard SQL.

This will fail with a syntax error under Legacy SQL. Since this test is already tagged with @Tag("disable_tpc"), you should revert it to the original Legacy SQL query.

Suggested change
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))";
String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

Comment on lines 1731 to +1732
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;";
"SELECT GENERATE_DATE_ARRAY('1900-01-01', '2000-01-01', INTERVAL 1 DAY) LIMIT 200";

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.

high

In testUseLegacySQLWithLargeResultsNotAllowedQueries, the connection is configured with QueryDialect=BIG_QUERY (Legacy SQL), but the query has been changed to "SELECT GENERATE_DATE_ARRAY('1900-01-01', '2000-01-01', INTERVAL 1 DAY) LIMIT 200", which is Standard SQL.

This will fail with a syntax error under Legacy SQL. Since this test is already tagged with @Tag("disable_tpc"), you should revert it to the original Legacy SQL query.

        "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

Comment on lines 1814 to +1815
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;";
"SELECT GENERATE_DATE_ARRAY('1000-01-01', '2000-01-01', INTERVAL 1 DAY) LIMIT 250000";

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.

high

In testUseLegacySQLWithLargeResultsAllowedWithNoDestinationTableDefaults, the connection is configured with QueryDialect=BIG_QUERY (Legacy SQL), but the query has been changed to "SELECT GENERATE_DATE_ARRAY('1000-01-01', '2000-01-01', INTERVAL 1 DAY) LIMIT 250000", which is Standard SQL.

This will fail with a syntax error under Legacy SQL. Since this test is already tagged with @Tag("disable_tpc"), you should revert it to the original Legacy SQL query.

        "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 250000;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

+ "LargeResultTable=FakeTable;";
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200;";
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))";

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.

high

In testDestinationTableWithMissingDestinationDatasetDefaults, the connection is configured with QueryDialect=BIG_QUERY (Legacy SQL), but the query has been changed to "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))", which is Standard SQL.

This will fail with a syntax error under Legacy SQL. Since this test is already tagged with @Tag("disable_tpc"), you should revert it to the original Legacy SQL query.

Suggested change
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200))";
String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

+ "EnableHighThroughputAPI=1;";
String selectLegacyQuery =
"SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200000;";
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200000))";

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.

high

In testHTAPIWithValidDestinationTableSavesQueriesWithLegacy, the query has been changed to "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200000))", which is Standard SQL.

If this test is meant to run in Legacy SQL mode (as indicated by the test name WithLegacy and the original query using Legacy SQL brackets [...]), this new query will fail with a syntax error. Please verify if this test is indeed using Legacy SQL and, if so, revert it to the original Legacy SQL query.

Suggested change
String selectLegacyQuery = "SELECT * FROM UNNEST(GENERATE_ARRAY(1, 200000))";
String selectLegacyQuery = "SELECT * FROM [bigquery-public-data.deepmind_alphafold.metadata] LIMIT 200000;";
References
  1. For integration tests, avoid refactoring existing tests to use isolated or unique datasets if they historically used a shared dataset and currently pass sequentially. Defer migration to unique datasets until parallel test execution is enabled.

String query =
"SELECT word FROM `bigquery-public-data.samples.shakespeare` WHERE"
+ " word LIKE 'X%' LIMIT 10";
"SELECT CONCAT('X', cast(word as STRING)) FROM UNNEST(GENERATE_ARRAY(1, 10)) AS word LIMIT 10";

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

In testSmallSelectAndVerifyResults, the query has been changed to use UNNEST(GENERATE_ARRAY(1, 10)) AS word.

Because the select expression CONCAT('X', cast(word as STRING)) is not aliased, the resulting column in the ResultSet will have an autogenerated name (e.g., _f0 or f0_) instead of "word". If the test attempts to retrieve the value by column name (e.g., resultSet.getString("word")), it will throw a SQLException.

To ensure compatibility, you should alias the select expression as word.

Suggested change
"SELECT CONCAT('X', cast(word as STRING)) FROM UNNEST(GENERATE_ARRAY(1, 10)) AS word LIMIT 10";
"SELECT CONCAT('X', cast(word as STRING)) AS word FROM UNNEST(GENERATE_ARRAY(1, 10)) AS word LIMIT 10";

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