druid icon indicating copy to clipboard operation
druid copied to clipboard

fix ColumnType to RelDataType conversion for nested arrays

Open clintropolis opened this issue 11 months ago • 0 comments

Description

RowSignatures.toRelDataType did not correctly handle conversion of nested array types such as ARRAY<ARRAY<LONG>> etc, since the ARRAY handling case only checked for the primitive column types. I have modified this code to split out the ColumnType to RelDataType conversion into a new method, RowSignatures. columnTypeToRelDataType, and handle arrays by recursively calling this method to convert the element type to a RelDataType so that it can handle any type of Druid array.

I kind of think this method maybe should be moved into Calcites since a bunch of the other conversion methods that don't involve RowSignature live there, but I haven't moved it yet...

Only the second added test would fail, despite just being a count(*) wrapper around the first one. Apparently this query used to run fine, but I believe the changes in #16033 which resulted in RowSignatures.toRelDataType started exercising this path a bit more frequently, which is how the problem was noticed.


This PR has:

  • [x] been self-reviewed.
  • [x] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
  • [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.
  • [x] been tested in a test Druid cluster.

clintropolis avatar Mar 15 '24 20:03 clintropolis