FrankChen021 commented on code in PR #20198:
URL: https://github.com/apache/druid/pull/20198#discussion_r3940694535


##########
sql/src/main/java/org/apache/druid/sql/SqlQueryPlus.java:
##########
@@ -272,6 +274,12 @@ public Builder auth(final AuthenticationResult authResult)
     public SqlQueryPlus build()
     {
       final StatementAndSetContext statementAndSetContext = 
DruidSqlParser.parse(sql, true);
+      try {
+        
QueryContextParameters.validate(statementAndSetContext.getSetContext());
+      }
+      catch (IllegalArgumentException e) {

Review Comment:
   [P1] Preserve bad-request semantics for parser failures
   
   QueryContextParameters.validate delegates the migrated integer and boolean 
descriptors to QueryContexts.getAsInt and getAsBoolean, which throw 
BadQueryContextException for malformed strings or wrong types. That exception 
is a QueryException, not an IllegalArgumentException, so this catch does not 
convert it to InvalidSqlInput. Since validation runs before HttpStatement 
creation, SqlResource.handleExceptionBeforeStatementCreated treats it as a 
non-Druid exception and returns an operator RUNTIME_FAILURE (HTTP 500) for 
inputs such as SET maxRowsQueuedForOrdering = 'not-an-int'; SELECT 1 or SET 
useResultLevelCache = 1; SELECT 1. Catch and convert parser failures here so 
all invalid recognized SET values remain HTTP 400 invalid SQL.



-- 
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]

Reply via email to