Method chaining order matters for BigQueryIO.readTableRows() and usingStandardSql()
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 4.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 196
Description
Depending on the order of the method calls you use in the fluent API for BigQueryIO.readTableRows() you'll either successfully execute a query requiring standard SQL or get an error indicating that you tried something incompatible with legacy SQL.
Works:
```
p.apply("Read rows will succeed", BigQueryIO.readTableRows().fromQuery(query.toString()).usingStandardSql());
```
Fails with a 400:
```
p.apply("Read rows will fail", BigQueryIO.readTableRows().usingStandardSql().fromQuery(query.toString()));
```
Error message (edited to anonymize):
"Invalid table name: `:.`\n[Try using standard SQL ([https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)](Try using standard SQL ([https://cloud.google.com/bigquery/docs/reference/standard-sql/enabling-standard-sql)).]
I wouldn't expect a fluent API to care about the ordering of the clauses. Even if a specific order were required, I would expect a more informative error message with a link to a grammar ...
See here for a complete example:
https://github.com/pbrumblay/bigqueryioproblems/blob/master/src/main/java/com/fearlesstg/UsingStandardSQLOrderMatters.java
Imported from Jira [BEAM-4363](https://issues.apache.org/jira/browse/BEAM-4363). Original Jira may contain additional context.
Reported by: pbrumblay.
Contributor guide
Assessment
This issue has not been assessed yet.