google / zetasql

ZetaSQL - Analyzer Framework for SQL
Apache License 2.0
2.32k stars 219 forks source link

Query parsing fails for queries with UNNEST #148

Open sridivakar opened 1 year ago

sridivakar commented 1 year ago

Tried to address this by adding UNNEST to reservable keywords, but it did not help.

import com.google.zetasql.LanguageOptions;
.
.

LanguageOptions languageOptions = new LanguageOptions();
.
.

languageOptions.enableReservableKeyword("UNNEST");

Here is the stacktrace, while parsing BQ sql with UNNEST :

[main] ERROR com.google.zetasql.toolkit.antipattern.parser.Main - Query parsing failed for query: SELECT * FROM `bq_antipattern.antipattern_output_table` , unnest(recommendation);
java.lang.NullPointerException: Cannot invoke "com.google.zetasql.parser.ASTNodes$ASTPathExpression.getNames()" because the return value of "com.google.zetasql.parser.ASTNodes$ASTTablePathExpression.getPathExpr()" is null
    at com.google.zetasql.toolkit.antipattern.parser.visitors.IdentifyCTEsEvalMultipleTimesVisitor.visit(IdentifyCTEsEvalMultipleTimesVisitor.java:94)
    at com.google.zetasql.parser.ASTNodes$ASTTablePathExpression.accept(ASTNodes.java:1450)
    at com.google.zetasql.parser.ParseTreeVisitor.descend(ParseTreeVisitor.java:45)
    at com.google.zetasql.parser.ASTNodes$ASTJoin.acceptChildren(ASTNodes.java:2651)
    at com.google.zetasql.parser.ParseTreeVisitor.defaultVisit(ParseTreeVisitor.java:36)
    at com.google.zetasql.parser.ParseTreeVisitor.visit(ParseTreeVisitor.java:162)
    at com.google.zetasql.parser.ASTNodes$ASTJoin.accept(ASTNodes.java:2642)
    at com.google.zetasql.parser.ParseTreeVisitor.descend(ParseTreeVisitor.java:45)
    at com.google.zetasql.parser.ASTNodes$ASTFromClause.acceptChildren(ASTNodes.java:1518)
    at com.google.zetasql.parser.ParseTreeVisitor.defaultVisit(ParseTreeVisitor.java:36)
    at com.google.zetasql.parser.ParseTreeVisitor.visit(ParseTreeVisitor.java:94)
    at com.google.zetasql.parser.ASTNodes$ASTFromClause.accept(ASTNodes.java:1512)
    at com.google.zetasql.parser.ParseTreeVisitor.descend(ParseTreeVisitor.java:45)
    at com.google.zetasql.parser.ASTNodes$ASTSelect.acceptChildren(ASTNodes.java:617)
    at com.google.zetasql.parser.ParseTreeVisitor.defaultVisit(ParseTreeVisitor.java:36)
    at com.google.zetasql.parser.ParseTreeVisitor.visit(ParseTreeVisitor.java:62)
    at com.google.zetasql.parser.ASTNodes$ASTSelect.accept(ASTNodes.java:607)
    at com.google.zetasql.parser.ParseTreeVisitor.descend(ParseTreeVisitor.java:45)
    at com.google.zetasql.parser.ASTNodes$ASTQuery.acceptChildren(ASTNodes.java:409)
    at com.google.zetasql.parser.ParseTreeVisitor.defaultVisit(ParseTreeVisitor.java:36)
    at com.google.zetasql.parser.ParseTreeVisitor.visit(ParseTreeVisitor.java:58)
    at com.google.zetasql.parser.ASTNodes$ASTQuery.accept(ASTNodes.java:402)
    at com.google.zetasql.parser.ParseTreeVisitor.descend(ParseTreeVisitor.java:45)
    at com.google.zetasql.parser.ASTNodes$ASTQueryStatement.acceptChildren(ASTNodes.java:224)
    at com.google.zetasql.parser.ParseTreeVisitor.defaultVisit(ParseTreeVisitor.java:36)
    at com.google.zetasql.parser.ParseTreeVisitor.visit(ParseTreeVisitor.java:54)
    at com.google.zetasql.parser.ASTNodes$ASTQueryStatement.accept(ASTNodes.java:218)
    at com.google.zetasql.toolkit.antipattern.parser.IdentifyCTEsEvalMultipleTimes.run(IdentifyCTEsEvalMultipleTimes.java:33)
    at com.google.zetasql.toolkit.antipattern.parser.Main$3.<init>(Main.java:152)
    at com.google.zetasql.toolkit.antipattern.parser.Main.getRecommendations(Main.java:150)
    at com.google.zetasql.toolkit.antipattern.parser.Main.main(Main.java:78)