yashmayya commented on code in PR #17047:
URL: https://github.com/apache/pinot/pull/17047#discussion_r2449656970
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/QueryEnvironment.java:
##########
@@ -174,12 +177,65 @@ public QueryEnvironment(String database, TableCache
tableCache, @Nullable Worker
.build());
}
+ /**
+ * Recursively checks if the SqlNode contains a NATURAL JOIN.
+ */
+ private boolean isNaturalJoinQuery(SqlNode sqlNode) {
Review Comment:
Why did you move away from the visitor pattern in earlier commits?
##########
pinot-query-planner/src/main/java/org/apache/pinot/query/QueryEnvironment.java:
##########
@@ -174,12 +177,65 @@ public QueryEnvironment(String database, TableCache
tableCache, @Nullable Worker
.build());
}
+ /**
+ * Recursively checks if the SqlNode contains a NATURAL JOIN.
+ */
+ private boolean isNaturalJoinQuery(SqlNode sqlNode) {
+ if (sqlNode == null) {
+ return false;
+ }
+ if (sqlNode instanceof SqlJoin) {
+ return ((SqlJoin) sqlNode).isNatural();
+ }
+ if (sqlNode instanceof SqlCall) {
+ SqlCall call = (SqlCall) sqlNode;
+ for (SqlNode operand : call.getOperandList()) {
+ if (isNaturalJoinQuery(operand)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Enhances validation error messages for specific scenarios like NATURAL
JOIN issues.
+ * To enhance the error message: Error Code: 700 (QueryValidationError)
+ * QueryValidationError: Index 58 out of bounds for length 54
+ *
+ */
+ private String enhanceNaturalJoinErrorMessage(SqlNode sqlNode, Throwable
originalError,
+ PlannerContext plannerContext) {
+ String originalMessage = originalError.getMessage();
+
+ if (originalError instanceof IndexOutOfBoundsException &&
isNaturalJoinQuery(sqlNode)) {
Review Comment:
This feels very hacky, if there's no better way of detecting the issue let's
remove it altogether IMO.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]