Steve Carlin has posted comments on this change. ( http://gerrit.cloudera.org:8080/25144 )
Change subject: IMPALA-14944: Throw UnsupportedFeatureException for some Calcite planner queries ...................................................................... Patch Set 2: (11 comments) http://gerrit.cloudera.org:8080/#/c/25144/2//COMMIT_MSG Commit Message: http://gerrit.cloudera.org:8080/#/c/25144/2//COMMIT_MSG@21 PS2, Line 21: "row__id" > Not very sure if I missed something important. But it looks like we do not The ParserException is thrown within the Parser.jj file It's Calcite's ParseException. http://gerrit.cloudera.org:8080/#/c/25144/2/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java File fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java: http://gerrit.cloudera.org:8080/#/c/25144/2/fe/src/main/java/org/apache/impala/analysis/AnalysisContext.java@529 PS2, Line 529: analysisResult_.shouldFallbackBecauseOfException() > Would it be okay too to pass 'analysisException' at https://gerrit.cloudera Changed it to your first suggestion. Can't evaluate analysisException instanceof UnsupportedFeatureException directly here because the original planner can also throw that exception. http://gerrit.cloudera.org:8080/#/c/25144/2/fe/src/main/java/org/apache/impala/service/Frontend.java File fe/src/main/java/org/apache/impala/service/Frontend.java: http://gerrit.cloudera.org:8080/#/c/25144/2/fe/src/main/java/org/apache/impala/service/Frontend.java@2521 PS2, Line 2521: // If there is any kind of exception from the first planner, we hit this code. > I know it's not added in this patch. But would it be a bit more informative I added more info to the comment, but I don't want to get too specific because if I mention an "UnsupportedFeatureException", it may be supported in the future and I don't want to worry about the comment being stale. http://gerrit.cloudera.org:8080/#/c/25144/2/fe/src/main/java/org/apache/impala/service/Frontend.java@2540 PS2, Line 2540: if (error instanceof InconsistentMetadataFetchException) { : throw (InconsistentMetadataFetchException) error; : } > I am a bit confused by this. I thought when error is an InconsistentMetadat Not sure why I had this here. Just retested and it seems to pass, so I removed it. http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java: http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteAnalysisDriver.java@151 PS2, Line 151: ComplexTableDetector.checkForComplexTables(parsedStmt_.getParsedSqlNode(), : queryCtx_, ctx_); > Would it make sense to add the following check to return earlier (v.s. call Ok, so I have an explanation... I didn't put it earlier for two reasons: 1) I would imagine most Impala users do not use complex tables, so this would incur an extra cost. Granted, it's not too much, so one can argue against this motive, but that was part of my thought process. This is in combination with #2 though... 2) I'm currently working on actually supporting complex tables and it is...well...complex. We support the following syntax which is very Impala specific: "select ... from complextbl, complextbl.array_col" The validator is gonna fail because array_col is in the from clause but is not an actual table. In order to handle this, we have to change the AST and use an "UNNEST(complextbl.array_col)". I suppose this logic can be done earlier? But now I'm starting to do some manipulations in the SqlNode tree that would be called by all queries just to handle some weird Impala syntax that no one else supports. So I suppose I feel better about handling this in the Exception syntax as opposed to handling it in the main flow? Idk...I suppose I could be talked out of it, but this code makes me sleep better at night :) So even though this code doesn't do any manipulations, it feels a bit similar to the other code I'm working on. I can change this to what you suggest, but I'm not gonna feel too comfortable about it. http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteQueryParser.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteQueryParser.java: http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteQueryParser.java@46 PS2, Line 46: ParseException > nit: Could we remove this since ParseException is also an ImpalaException? Done http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteSingleNodePlanner.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteSingleNodePlanner.java: http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteSingleNodePlanner.java@78 PS2, Line 78: new CalciteOptimizer(analysisResult_, ctx_.getTimeline(), ctx_.getQueryOptions()); > line too long (92 > 90) Done http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/CalciteSingleNodePlanner.java@94 PS2, Line 94: e instanceof InconsistentMetadataFetchException > Would it make the code easier to understand if we add a code comment descri I'm gonna leave this one alone...I think the exception itself self-describes what is going on here. http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java: http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java@103 PS2, Line 103: if (spec.getTypeName().names.get(0).toLowerCase().equals("uuid")) > Would it be clearer if we add a short code comment giving an example that w Done http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/ImpalaSqlValidatorImpl.java@181 PS2, Line 181: SqlNodeList columnList = withItem.columnList; : if (columnList != null) { : final RelDataType rowType = getValidatedNodeType(withItem.query); : final int fieldCount = rowType.getFieldCount(); : if (columnList.size() != fieldCount) { : throw new CalciteContextException("", new UnsupportedFeatureException( : "Number of columns in with clause must match number of query columns")); : } : } > Would it be clearer if we add a code comment saying that it's the same as t Added comment http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/UnsupportedChecker.java File java/calcite-planner/src/main/java/org/apache/impala/calcite/service/UnsupportedChecker.java: http://gerrit.cloudera.org:8080/#/c/25144/2/java/calcite-planner/src/main/java/org/apache/impala/calcite/service/UnsupportedChecker.java@119 PS2, Line 119: if (stmt.contains("`" + m.group(1) + "`")) { : throw new UnsupportedFeatureException( : "Backticks around column " + m.group(1) + " is not supported."); : } > I verified that the following query could exercise this code path. So it works some of the time... But the backticks also seem to have a special meaning. I haven't really dug too deep into how this works yet. But the following query in our test suite fails: with t as (values(1), (2), (3), (4)) select min(t1.`1` + t2.`1`) from t t1 join t t2; -- To view, visit http://gerrit.cloudera.org:8080/25144 To unsubscribe, visit http://gerrit.cloudera.org:8080/settings Gerrit-Project: Impala-ASF Gerrit-Branch: master Gerrit-MessageType: comment Gerrit-Change-Id: I037d636064c4c99131598b7424dd99e4ad56d30f Gerrit-Change-Number: 25144 Gerrit-PatchSet: 2 Gerrit-Owner: Steve Carlin <[email protected]> Gerrit-Reviewer: Aleksandr Efimov <[email protected]> Gerrit-Reviewer: Aman Sinha <[email protected]> Gerrit-Reviewer: Fang-Yu Rao <[email protected]> Gerrit-Reviewer: Impala Public Jenkins <[email protected]> Gerrit-Reviewer: Joe McDonnell <[email protected]> Gerrit-Reviewer: Michael Smith <[email protected]> Gerrit-Reviewer: Steve Carlin <[email protected]> Gerrit-Comment-Date: Sat, 24 Oct 2026 15:47:57 +0000 Gerrit-HasComments: Yes
