Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors result handling in BigQueryStatement to process query results directly from Job objects, enabling dynamic SQL type determination and consistent application of maximum results page size settings across child jobs during script executions. Additionally, new unit and integration tests have been added to verify script execution behavior and result set selection (JSON vs. Arrow/Read API). I have no feedback to provide as there are no review comments.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Multi-statement
SCRIPTqueries failed to activate the BigQuery Storage Read API (HTAPI / Arrow) on childSELECTjobs even whenEnableHighThroughputAPI=1and result sizes exceeded the Read API activation thresholds.Root Cause
SELECTqueries,BigQueryStatement.executeJob(...)fetches initial results viajob.getQueryResults(QueryResultsOption.pageSize(querySettings.getMaxResultPerPage()))(defaultMaxResults=10000).QueryJobConfiguration.Builder.setMaxResults(...)on aSCRIPTquery only applies to the parent coordinator job, not to the child jobs spawned by BigQuery.SCRIPTchild-job result paths —BigQueryStatement.handleQueryResult(...)(case SCRIPT:) andBigQueryStatement.getMoreResultsImpl(...)— calledcurrentJob.getQueryResults()with no options. Without apageSizeoption,tabledata.listfetches up to 10 MB of rows in the first REST page, either fitting the entire result into page 1 (!results.hasNextPage()) or inflatingrowsInPagesomeetsReadRatio(...)evaluates tofalseand silently falls back toBigQueryJsonResultSet.Fix
BigQueryStatement.handleQueryResult(String query, Job job)overload that resolvesStatementTypeandSqlTypefromjob, fetches results withQueryResultsOption.pageSize(querySettings.getMaxResultPerPage()), and delegates tohandleQueryResult(query, results, sqlType, job).case SCRIPT:inhandleQueryResultandgetMoreResultsImplto delegate tohandleQueryResult(query, currentJob), eliminating duplicated child-job handling logic.Tests
BigQueryStatementTest: added unit tests coveringhandleQueryResult(String, Job)directly as well as multi-statementSCRIPTexecution acrossexecute(...)andgetMoreResults(), verifyingQueryResultsOption.pageSize(maxResults)is applied to every child job andBigQueryArrowResultSetis activated for largeSELECTchild jobs while preserving DML update counts andBigQueryJsonResultSetfor smallSELECTchild jobs.ITStatementTest: updatedtestScriptto assertBigQueryArrowResultSetand row counts across all 3 script statements viagetMoreResults().ITCallableStatementTest: addedtestCallableStatementScriptWithReadApicoveringCALL+ multi-SELECTscript execution with Read API enabled.