Details
-
Improvement
-
Status: In Progress
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
After https://github.com/apache/calcite/commit/515f3356a6a1ab4bd570c1c20bec9a7e5d4aca5f#diff-e873041549333502af52ece8a1b34301ae5a059ff4719e9bddbaef48929e7047 there appears to be an issue with JavaCC codegen of the Parser.jj template in "newer" versions of JavaCC (6.1.2 was the version I tested).
build/scala_2.10/generated-sources/java/com/redacted/query/sql/parser/impl/QuerySqlParserImpl.java:15266: error: variable startNum might not have been initialized startNum.intValue(true) != endNum.intValue(true), ^ redacted/build/scala_2.10/generated-sources/java/com/redacted/query/sql/parser/impl/QuerySqlParserImpl.java:15266: error: variable endNum might not have been initialized startNum.intValue(true) != endNum.intValue(true), ^ redacted/build/scala_2.10/generated-sources/java/com/redacted/query/sql/parser/impl/QuerySqlParserImpl.java:15281: error: variable startNum might not have been initialized span().end(e), e, startNum, endNum, reluctant);} ^ redacted/build/scala_2.10/generated-sources/java/com/redacted/query/sql/parser/impl/QuerySqlParserImpl.java:15281: error: variable endNum might not have been initialized span().end(e), e, startNum, endNum, reluctant);} ^ redacted/build/scala_2.10/generated-sources/java/com/redacted/query/sql/parser/impl/QuerySqlParserImpl.java:15281: error: variable reluctant might not have been initialized span().end(e), e, startNum, endNum, reluctant);}
jbalint@gmail.com helped me debug this, and he pointed out which generated code was incorrect:
final public SqlNode PatternFactor() throws ParseException {final SqlNode e; final SqlNode extra; final SqlLiteral startNum; final SqlLiteral endNum; final SqlLiteral reluctant; ... default: jj_la1[163] = jj_gen; {if ("" != null) return e;} } {if ("" != null) return SqlStdOperatorTable.PATTERN_QUANTIFIER.createCall( span().end(e), e, startNum, endNum, reluctant);} throw new Error("Missing return statement in function"); }
instead of:
default: jj_la1[163] = jj_gen; {if (true) return e;} } {if (true) return SqlStdOperatorTable.PATTERN_QUANTIFIER.createCall( span().end(e), e, startNum, endNum, reluctant);} throw new Error("Missing return statement in function"); }
I've worked around this by pinning to JavaCC 4.0, however the Gradle JavaCC plugin we use https://github.com/javacc/javaccPlugin defaults to 6.1.2.
It looks like JavaCC 4.0 was release in 2006, 6.1.2 in 2014, and current 7.0.12 in 2022 so it felt like it might be worth updating.
If this is intended / known, feel free to close - Thanks
Attachments
Issue Links
- causes
-
CALCITE-6466 Add benchmark for SQL parser instantiation
- Closed
- is related to
-
CALCITE-1012 Benchmark SQL parser
- Open