kbastani opened a new issue #7922: URL: https://github.com/apache/pinot/issues/7922
The following SQL query will cause an error when using `MIN` or `MAX`. ```SQL SELECT MAX(calcs.int0) AS TEMP_Test__645427419__0_ FROM calcs HAVING (COUNT(1) > 0) ``` The error produced is as follows: ```JSON [ { "message": "QueryExecutionError: java.lang.IndexOutOfBoundsException: Index: 0 \tat java.base/java.util.Collections$EmptyList.get(Collections.java:4553) \tat org.apache.pinot.core.plan.DictionaryBasedAggregationPlanNode.<init>(DictionaryBasedAggregationPlanNode.java:52) \tat org.apache.pinot.core.plan.maker.InstancePlanMakerImplV2.makeSegmentPlanNode(InstancePlanMakerImplV2.java:231) \tat org.apache.pinot.core.plan.maker.InstancePlanMakerImplV2.makeInstancePlan(InstancePlanMakerImplV2.java:187)", "errorCode": 200 } ] ``` There are multiple ways to work around the exception. This workaround checks for a NULL value for the `calcs.int0` field. ```SQL SELECT MAX(calcs.int0) AS TEMP_Test__645427419__0_ FROM calcs WHERE calcs.int0 IS NOT NULL HAVING (COUNT(1) > 0) ``` This workaround adds a `COUNT(1)` as a field in the `SELECT` clause. ```SQL SELECT MAX(calcs.int0) AS TEMP_Test__645427419__0_, COUNT(1) FROM calcs HAVING (COUNT(1) > 0) ``` Another relevant condition for reproducing this issue is to set a `defaultNullValue` in the schema configuration for the table. Also, `nullHandlingEnabled` has been set to `true` in the table configuration. Table configuration for reproducing the issue: ```JSON { "tableName":"calcs", "segmentsConfig":{ "segmentAssignmentStrategy":"BalanceNumSegmentAssignmentStrategy", "segmentPushType":"APPEND", "schemaName":"calcs", "replication":1 }, "tableIndexConfig":{ "invertedIndexColumns":[ ], "loadMode":"MMAP", "nullHandlingEnabled": true }, "tenants":{ "broker":"DefaultTenant", "server":"DefaultTenant" }, "tableType":"OFFLINE", "metadata":{ "customConfigs":{} } } ``` Schema for reproducing the issue: ```JSON { "schemaName":"calcs", "dimensionFieldSpecs":[ { "name":"int0", "dataType":"INT", "defaultNullValue": 0 } ] } ``` -- 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 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