Akshat-Jain opened a new pull request, #16865:
URL: https://github.com/apache/druid/pull/16865

   ### Description
   
   Currently, queries like the following give IndexOutOfBoundsException error 
because we attempt to create a frame writer for empty RAC.
   
   ```sql
   select countryName, row_number() over () as c1
   from wikipedia
   where countryName in ('non-existent-country')
   group by countryName, cityName, channel
   ```
   
   The above query gives:
   
   ```java
    Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for 
length 0
        at 
java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
        at 
java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
        at 
java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
        at java.base/java.util.Objects.checkIndex(Objects.java:374)
        at java.base/java.util.ArrayList.get(ArrayList.java:459)
        at 
org.apache.druid.query.rowsandcols.ConcatRowsAndColumns.findColumn(ConcatRowsAndColumns.java:95)
        at 
org.apache.druid.query.rowsandcols.semantic.DefaultColumnSelectorFactoryMaker$ColumnAccessorBasedColumnSelectorFactory.withColumnAccessor(DefaultColumnSelectorFactoryMaker.java:183)
        at 
org.apache.druid.query.rowsandcols.semantic.DefaultColumnSelectorFactoryMaker$ColumnAccessorBasedColumnSelectorFactory.makeDimensionSelector(DefaultColumnSelectorFactoryMaker.java:83)
        at 
org.apache.druid.frame.field.FieldWriters.makeStringWriter(FieldWriters.java:132)
        at 
org.apache.druid.frame.field.FieldWriters.create(FieldWriters.java:78)
        at 
org.apache.druid.frame.write.RowBasedFrameWriterFactory.makeFieldWriters(RowBasedFrameWriterFactory.java:117)
        at 
org.apache.druid.frame.write.RowBasedFrameWriterFactory.newFrameWriter(RowBasedFrameWriterFactory.java:76)
        at 
org.apache.druid.msq.querykit.WindowOperatorQueryFrameProcessor.createFrameWriterIfNeeded(WindowOperatorQueryFrameProcessor.java:407)
        at 
org.apache.druid.msq.querykit.WindowOperatorQueryFrameProcessor.flushAllRowsAndCols(WindowOperatorQueryFrameProcessor.java:394)
   ```
   
   This PR fixes it and adds a test that fails with the above stacktrace 
without this PR's change.
   
   <hr>
   
   This PR has:
   
   - [x] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked 
related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in 
[licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, 
ensuring the threshold for [code 
coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md)
 is met.
   - [ ] added integration tests.
   - [ ] been tested in a test Druid cluster.
   


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