Validate BigQuery Script with Zetasql
- Dominant language
- C++
- Stars
- 2.6k
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description
Hi, we have been using zetasql analyzer to validate our generated sql statement for BigQuery. Recently we have decided to generate multi-statement sql like:
```
BEGIN
CREATE TEMP TABLE TempTable1(columnName STRING) AS select columnName from projectId.dataset.tableName where (((partitionColumn >= '2022-12-31') and (partitionColumn < '2023-01-03')) and ((localDatetimeColumn >= '2023-1-1') and (localDatetimeColumn < '2023-1-2')));
CREATE TEMP TABLE TempTable2(columnName STRING) AS select columnName from TempTable1 where (upper(CompanyGuid) in ('COMPANYGUID') and GroupId in ('groupId'));
select columnName from TempTable2 where DeviceId in ('deviceId') limit 1;
END
```
But we failed to validate the above statement with zetasql with following config:
```
LanguageOptions languageOptions = new LanguageOptions();
languageOptions.supportsStatementKind(ZetaSQLResolvedNodeKind.ResolvedNodeKind.RESOLVED_QUERY_STMT);
languageOptions.supportsStatementKind(ZetaSQLResolvedNodeKind.ResolvedNodeKind.RESOLVED_CREATE_TABLE_AS_SELECT_STMT);
languageOptions.enableMaximumLanguageFeatures();
AnalyzerOptions analyzerOptions = new AnalyzerOptions();
analyzerOptions.setLanguageOptions(languageOptions);
Analyzer.extractTableNamesFromScript(sql, analyzerOptions);
```
I am wondering if anyone could advise? Thanks!
Contributor guide
Research direction
Start with Analyzer.extractTableNamesFromScript(sql, analyzerOptions) and the configured LanguageOptions in the issue. Reproduce the failure with the supplied multi-statement BigQuery SQL, then determine what analyzer support or configuration is needed for the script to validate and extract table names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100