LakshSingla commented on code in PR #16800:
URL: https://github.com/apache/druid/pull/16800#discussion_r1710009760
##########
processing/src/main/java/org/apache/druid/query/operator/WindowOperatorQueryQueryToolChest.java:
##########
@@ -116,6 +128,36 @@ public Sequence<Object[]> resultsAsArrays(
return (Sequence) resultSequence;
}
+ @Override
+ public Optional<Sequence<FrameSignaturePair>> resultsAsFrames(
+ WindowOperatorQuery query,
+ Sequence<RowsAndColumns> resultSequence,
+ MemoryAllocatorFactory memoryAllocatorFactory,
+ boolean useNestedForUnknownTypes
+ )
+ {
Review Comment:
I agree that the code is trying to do things roundaboutly. I did try using
`FrameMaker,` however, due to the `RowsAndColumnsUnravelingQueryRunner`, the
sequence of RACs is a sequence of rows. Therefore it throws a
`ClassCastException`:
```
class [Ljava.lang.Object; cannot be cast to class
org.apache.druid.query.rowsandcols.RowsAndColumns
```
Setting `unravel` to false in the `ClientQuerySegmentWalker` when we know
the results would be materialized as frames pose the same problem when trying
to materialize the results as rows `resultsAsArrays`. The way I see it, the
`ClientQuerySegmentWalker` should know if it's trying to materialize the
results as arrays or frames, and depending on that set `unravel` to true/false.
This leaks the implementation of the window tool chest to the calling class
(`ClientQuerySegmentWalker`) where it should have been abstracted out. Do let
me know if that is fine, or if there's a better resolution.
FWIW here's the cleaned up `implementation` of the `resultsAsFrames` in case
I misinterpreted your comment:
```java
{
return Optional.of(
resultSequence.map(
rac -> {
FrameMaker frameMaker = FrameMaker.fromRAC(rac);
return new FrameSignaturePair(
frameMaker.toColumnBasedFrame(),
frameMaker.computeSignature()
);
}
)
);
```
--
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]