richard-misiak-az opened a new issue, #13699:
URL: https://github.com/apache/pinot/issues/13699

   When using the multi-stage engine if you select a constant value in a CTE or 
subquery and then try to filter that constant column you get a SQL parsing 
error. 
   
   
   The simplest query I've found that demonstrates this is:
   ```sql
   with data as (
     select 'test' as "foo" from example
   ) 
   select * from data where "foo" = 'test'
   ```
   
   fails with the error 
   
   ```java
   ProcessingException(errorCode:150, message:SQLParsingError:
   java.lang.Exception: Unable to find table for this query
        at 
org.apache.pinot.controller.api.resources.PinotQueryResource.getMultiStageQueryResponse(PinotQueryResource.java:214)
        at 
org.apache.pinot.controller.api.resources.PinotQueryResource.executeSqlQuery(PinotQueryResource.java:177)
        at 
org.apache.pinot.controller.api.resources.PinotQueryResource.handlePostSql(PinotQueryResource.java:125)
        at jdk.internal.reflect.GeneratedMethodAccessor402.invoke(Unknown 
Source)
   ...
   Caused by: java.lang.RuntimeException: Error composing query plan for: with 
data as (
     select 'test' as "foo" from example
   ) 
   select * from data where "foo" = 'test'
        at 
org.apache.pinot.query.QueryEnvironment.getTableNamesForQuery(QueryEnvironment.java:218)
   ...
   Caused by: java.lang.UnsupportedOperationException: Cannot generate a valid 
execution plan for the given query: LogicalFilter(condition=[=($0, 
_UTF-8'test')])
     LogicalProject(foo=[_UTF-8'test'])
       LogicalTableScan(table=[[example]])
        at 
org.apache.pinot.query.QueryEnvironment.optimize(QueryEnvironment.java:323)
        at 
org.apache.pinot.query.QueryEnvironment.compileQuery(QueryEnvironment.java:261)
   ...
   Caused by: org.apache.pinot.sql.parsers.SqlCompilationException: Caught 
exception while invoking method: public static boolean 
org.apache.pinot.common.function.scalar.ComparisonFunctions.equals(double,double)
 with arguments: [test, test]
        at 
org.apache.calcite.rel.rules.PinotEvaluateLiteralRule.evaluateLiteralOnlyFunction(PinotEvaluateLiteralRule.java:197)
        at 
org.apache.calcite.rel.rules.PinotEvaluateLiteralRule$EvaluateLiteralShuttle.visitCall(PinotEvaluateLiteralRule.java:137)
        at 
org.apache.calcite.rel.rules.PinotEvaluateLiteralRule$EvaluateLiteralShuttle.visitCall(PinotEvaluateLiteralRule.java:121)
        at org.apache.calcite.rex.RexCall.accept(RexCall.java:189)
   ...
   Caused by: java.lang.NumberFormatException: For input string: "test"
        at 
java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)
        at 
java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
        at java.base/java.lang.Double.parseDouble(Double.java:543)
        at 
org.apache.pinot.common.utils.PinotDataType$11.toDouble(PinotDataType.java:622))
   ```
   
   where it appears that it is trying to do a double comparison on the column 
instead of a string.


-- 
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: commits-unsubscr...@pinot.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to