-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(bqjdbc): pass rowsInPage with TableResult #13238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
355331b
9c142bf
1351b4b
f1099a2
daee960
71a8e32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,3 +86,7 @@ monorepo | |
| *.tfstate.lock.info | ||
|
|
||
| .jqwik-database | ||
|
|
||
| # Agent configuration and local skills | ||
| .agent/ | ||
| .agents/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1685,6 +1685,7 @@ && getOptions().getOpenTelemetryTracer() != null) { | |
| .setSchema(schema) | ||
| .setTotalRows(data.y()) | ||
| .setPageNoSchema(data.x()) | ||
| .setRowsInPage(data.x() != null ? (long) Iterables.size(data.x().getValues()) : 0L) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we guarantee somehow that it would be using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can guarantee But if we want we can add an explicit instanceof check here. Should I add it? |
||
| .build(); | ||
| } finally { | ||
| if (tableDataList != null) { | ||
|
|
@@ -2016,6 +2017,7 @@ public com.google.api.services.bigquery.model.QueryResponse call() | |
| .setJobId(jobId) | ||
| .setQueryId(results.getQueryId()) | ||
| .setJobCreationReason(JobCreationReason.fromPb(results.getJobCreationReason())) | ||
| .setRowsInPage(results.getRows() != null ? (long) results.getRows().size() : 0L) | ||
| .build(); | ||
| } | ||
| // only 1 page of result | ||
|
|
@@ -2035,6 +2037,7 @@ public com.google.api.services.bigquery.model.QueryResponse call() | |
| results.getJobReference() != null ? JobId.fromPb(results.getJobReference()) : null) | ||
| .setQueryId(results.getQueryId()) | ||
| .setJobCreationReason(JobCreationReason.fromPb(results.getJobCreationReason())) | ||
| .setRowsInPage(results.getRows() != null ? (long) results.getRows().size() : 0L) | ||
| .build(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,6 +49,8 @@ public abstract static class Builder { | |
|
|
||
| public abstract TableResult.Builder setJobCreationReason(JobCreationReason jobCreationReason); | ||
|
|
||
| public abstract TableResult.Builder setRowsInPage(Long rowsInPage); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Is is possible to keep this setter package-private for now? I think it's only used internally and we can make it public if there is a need. |
||
|
|
||
| /** Creates a @code TableResult} object. */ | ||
| public abstract TableResult build(); | ||
| } | ||
|
|
@@ -81,6 +83,10 @@ public static Builder newBuilder() { | |
| @Nullable | ||
| public abstract JobCreationReason getJobCreationReason(); | ||
|
|
||
| /** Returns the number of rows in the current page of results. */ | ||
| @Nullable | ||
| public abstract Long getRowsInPage(); | ||
|
|
||
| @Override | ||
| public boolean hasNextPage() { | ||
| return getPageNoSchema().hasNextPage(); | ||
|
|
@@ -94,12 +100,18 @@ public String getNextPageToken() { | |
| @Override | ||
| public TableResult getNextPage() { | ||
| if (getPageNoSchema().hasNextPage()) { | ||
| Page<FieldValueList> nextPageNoSchema = getPageNoSchema().getNextPage(); | ||
| long nextRows = | ||
| nextPageNoSchema.getValues() != null | ||
| ? (long) Iterables.size(nextPageNoSchema.getValues()) | ||
| : 0L; | ||
|
Comment on lines
+103
to
+107
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. qq, similar to the question Kirill mentioned above. If Would that end up increasing the overall time? For example O(n) here in the |
||
| return TableResult.newBuilder() | ||
| .setSchema(getSchema()) | ||
| .setTotalRows(getTotalRows()) | ||
| .setPageNoSchema(getPageNoSchema().getNextPage()) | ||
| .setPageNoSchema(nextPageNoSchema) | ||
| .setQueryId(getQueryId()) | ||
| .setJobCreationReason(getJobCreationReason()) | ||
| .setRowsInPage(nextRows) | ||
| .build(); | ||
| } | ||
| return null; | ||
|
|
@@ -137,12 +149,14 @@ public String toString() { | |
| .add("totalRows", getTotalRows()) | ||
| .add("cursor", getNextPageToken()) | ||
| .add("queryId", getQueryId()) | ||
| .add("rowsInPage", getRowsInPage()) | ||
| .toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public final int hashCode() { | ||
| return Objects.hash(getPageNoSchema(), getSchema(), getTotalRows(), getQueryId()); | ||
| return Objects.hash( | ||
| getPageNoSchema(), getSchema(), getTotalRows(), getQueryId(), getRowsInPage()); | ||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -158,6 +172,7 @@ public final boolean equals(Object obj) { | |
| && Iterators.elementsEqual(getValues().iterator(), response.getValues().iterator()) | ||
| && Objects.equals(getSchema(), response.getSchema()) | ||
| && getTotalRows() == response.getTotalRows() | ||
| && getQueryId() == response.getQueryId(); | ||
| && Objects.equals(getQueryId(), response.getQueryId()) | ||
| && Objects.equals(getRowsInPage(), response.getRowsInPage()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qq, is this intended to be added?