Skip to content

Commit 4c70cf6

Browse files
committed
refactor(bigquery): simplify empty PageImpl and use readSession estimatedRowCount in slow-path fallback
1 parent 98d9e6a commit 4c70cf6

1 file changed

Lines changed: 4 additions & 19 deletions

File tree

  • java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery

‎java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,11 +3120,7 @@ private TableResult queryFallbackArrow(
31203120
return TableResult.newBuilder()
31213121
.setSchema(schema)
31223122
.setTotalRows(numDmlAffectedRows != null ? numDmlAffectedRows : 0L)
3123-
.setPageNoSchema(
3124-
new PageImpl<>(
3125-
new TableDataPageFetcher(null, schema, getOptions(), null, optionMap(options)),
3126-
null,
3127-
ImmutableList.of()))
3123+
.setPageNoSchema(new PageImpl<>(null, null, ImmutableList.of()))
31283124
.setJobId(completedJob.getJobId())
31293125
.setRowsInPage(0L)
31303126
.setStatementType(statementType)
@@ -3153,29 +3149,18 @@ private TableResult queryFallbackArrow(
31533149
firstPage != null ? ImmutableList.copyOf(firstPage.getValues()) : ImmutableList.of();
31543150
long rowsInPage = (long) firstPageRows.size();
31553151

3156-
Table destTable = null;
3157-
try {
3158-
destTable = getTable(destinationTable);
3159-
} catch (Exception e) {
3160-
// Non-fatal table lookup failure
3161-
}
31623152
long totalRows =
31633153
numDmlAffectedRows != null
31643154
? numDmlAffectedRows
3165-
: (destTable != null && destTable.getNumRows() != null
3166-
? destTable.getNumRows().longValue()
3155+
: (readSession.getEstimatedRowCount() > 0
3156+
? readSession.getEstimatedRowCount()
31673157
: rowsInPage);
31683158

31693159
return TableResult.newBuilder()
31703160
.setSchema(schema)
31713161
.setTotalRows(totalRows)
31723162
.setPageNoSchema(
3173-
firstPage != null
3174-
? firstPage
3175-
: new PageImpl<>(
3176-
new TableDataPageFetcher(null, schema, getOptions(), null, optionMap(options)),
3177-
null,
3178-
ImmutableList.of()))
3163+
firstPage != null ? firstPage : new PageImpl<>(null, null, ImmutableList.of()))
31793164
.setJobId(completedJob.getJobId())
31803165
.setRowsInPage(rowsInPage)
31813166
.setStatementType(statementType)

0 commit comments

Comments
 (0)