Claus Ibsen created CAMEL-27700:
-----------------------------------
Summary: camel-google-bigquery: projectId ignored with
connectionFactory, JobId header reused, more
Key: CAMEL-27700
URL: https://issues.apache.org/jira/browse/CAMEL-27700
Project: Camel
Issue Type: Bug
Components: camel-google-bigquery
Reporter: Claus Ibsen
Fix For: 4.24.0
Found while improving the option descriptions of camel-google-bigquery for
CAMEL-23832 (PR (commit
https://github.com/apache/camel/commit/b219a67784afde6f58f6cea8c04205870721e79f)).
These are separate problems of the component; the descriptions commit only
documents the current behavior.
h4. 1. google-bigquery ignores the projectId of the URI when a
connectionFactory is set
{{GoogleBigQueryProducer.process(String, String, String, List, String)}} builds
the request with {{InsertAllRequest.newBuilder(configuration.getDatasetId(),
tableIdWithPartition)}}, so the {{TableId}} has no project.
{{BigQueryImpl.insertAll}} then uses the default project of the client. The
endpoint sets {{projectId}} on the client only when it creates the connection
factory itself, in {{GoogleBigQueryEndpoint.doStart()}}. With a
{{connectionFactory}} on the endpoint or the component, the rows go to the
dataset in the project of that client, and {{projectId}} of the URI, which is
required, is not used.
Proposed change: build the request with
{{TableId.of(configuration.getProjectId(), datasetId, table)}}.
h4. 2. google-bigquery-sql: the CamelGoogleBigQueryJobId header makes the next
endpoint return the previous result
After a SELECT with {{outputType=SELECT_LIST}},
{{GoogleBigQuerySQLProducer.processSelectQueryJob}} sets the
{{CamelGoogleBigQueryJobId}} header and leaves it on the message.
{{GoogleBigQuerySQLProducer.process}} reads that header, and when it is set,
{{executeJob}} returns the existing job instead of running the query. A second
google-bigquery-sql endpoint later in the same route (another query) then
returns the result of the first job, without an error.
Proposed change: only use the header for paging (together with
{{CamelGoogleBigQueryPageToken}}), or check that the job belongs to the query
of the endpoint; at least document that the header must be removed before
another google-bigquery-sql endpoint.
h4. 3. google-bigquery: in a grouped exchange, an exchange without the table
header goes to the table of the exchange before it
{{GoogleBigQueryProducer.process(Exchange)}} and {{checkTableIds}} read
{{CamelGoogleBigQueryTableId}} with the table of the previous exchange as the
default value, not the {{tableId}} of the endpoint. The
{{CamelGoogleBigQueryTableSuffix}} and
{{CamelGoogleBigQueryPartitionDecorator}} headers fall back to none instead. So
in a group where only the first exchange has the header, all the rows go to
that table.
Proposed change: fall back to the {{tableId}} of the endpoint for every
exchange, like the other two headers.
h4. 4. Component options projectId and datasetId do nothing
{{GoogleBigQueryComponent}} has the options {{projectId}} and {{datasetId}},
and {{GoogleBigQuerySQLComponent}} has {{projectId}}. {{createEndpoint}} never
reads them: the endpoint takes both values from the URI path, which is
required. Setting them on the component has no effect.
Proposed change: use them as defaults for the endpoint (the path would then
need to allow leaving them out), or deprecate them.
h4. 5. Doc page of google-bigquery-sql: wrong example and wrong STREAM_LIST note
* The example {{google-bigquery-sql://project-17248459::classpath:delete.sql}}
has a double colon. {{GoogleBigQuerySQLConfiguration.parseRemaining}} keeps
everything after the first colon, so the query string is
{{:classpath:delete.sql}}, which {{SqlHelper.resolveQuery}} does not load as a
resource. It should be
{{google-bigquery-sql:project-17248459:classpath:delete.sql}}.
* The STREAM_LIST section says that it does not support {{pageToken}}.
{{GoogleBigQuerySQLProducer.processSelectQueryJob}} passes the page token
(header or option) to {{getQueryResults}} for STREAM_LIST too, so the iterator
starts at that page.
h4. 6. Stale class Javadoc of the endpoints
The Javadoc of {{GoogleBigQueryEndpoint}} and {{GoogleBigQuerySQLEndpoint}},
after the first sentence, describes URI parameters that do not exist (Logger
ID, Partitioned) and a table for the SQL endpoint. It can be removed.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)