-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deduce type from the aggregators when materializing subquery results #16703
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,14 +427,7 @@ public Function<Result<TimeseriesResultValue>, Result<TimeseriesResultValue>> ma | |
@Override | ||
public RowSignature resultArraySignature(TimeseriesQuery query) | ||
{ | ||
RowSignature.Builder rowSignatureBuilder = RowSignature.builder(); | ||
rowSignatureBuilder.addTimeColumn(); | ||
if (StringUtils.isNotEmpty(query.getTimestampResultField())) { | ||
rowSignatureBuilder.add(query.getTimestampResultField(), ColumnType.LONG); | ||
} | ||
rowSignatureBuilder.addAggregators(query.getAggregatorSpecs(), RowSignature.Finalization.UNKNOWN); | ||
rowSignatureBuilder.addPostAggregators(query.getPostAggregatorSpecs()); | ||
return rowSignatureBuilder.build(); | ||
return resultSignature(query, RowSignature.Finalization.UNKNOWN); | ||
} | ||
|
||
@Override | ||
|
@@ -474,7 +467,11 @@ public Optional<Sequence<FrameSignaturePair>> resultsAsFrames( | |
boolean useNestedForUnknownTypes | ||
) | ||
{ | ||
final RowSignature rowSignature = resultArraySignature(query); | ||
final RowSignature rowSignature = | ||
resultSignature( | ||
query, | ||
query.context().isFinalize(true) ? RowSignature.Finalization.YES : RowSignature.Finalization.NO | ||
); | ||
final Pair<Cursor, Closeable> cursorAndCloseable = IterableRowsCursorHelper.getCursorFromSequence( | ||
resultsAsArrays(query, resultSequence), | ||
rowSignature | ||
|
@@ -535,4 +532,16 @@ private Function<Result<TimeseriesResultValue>, Result<TimeseriesResultValue>> m | |
); | ||
}; | ||
} | ||
|
||
private RowSignature resultSignature(final TimeseriesQuery query, final RowSignature.Finalization finalization) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can this method be moved to be: |
||
{ | ||
RowSignature.Builder rowSignatureBuilder = RowSignature.builder(); | ||
rowSignatureBuilder.addTimeColumn(); | ||
if (StringUtils.isNotEmpty(query.getTimestampResultField())) { | ||
rowSignatureBuilder.add(query.getTimestampResultField(), ColumnType.LONG); | ||
} | ||
rowSignatureBuilder.addAggregators(query.getAggregatorSpecs(), finalization); | ||
rowSignatureBuilder.addPostAggregators(query.getPostAggregatorSpecs()); | ||
return rowSignatureBuilder.build(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -558,7 +558,16 @@ public Optional<Sequence<FrameSignaturePair>> resultsAsFrames( | |
boolean useNestedForUnknownTypes | ||
) | ||
{ | ||
final RowSignature rowSignature = resultArraySignature(query); | ||
final RowSignature rowSignature = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. similarily to |
||
RowSignature.builder() | ||
.addTimeColumn() | ||
.addDimensions(Collections.singletonList(query.getDimensionSpec())) | ||
.addAggregators( | ||
query.getAggregatorSpecs(), | ||
query.context().isFinalize(true) ? RowSignature.Finalization.YES : RowSignature.Finalization.NO | ||
) | ||
.addPostAggregators(query.getPostAggregatorSpecs()) | ||
.build(); | ||
final Pair<Cursor, Closeable> cursorAndCloseable = IterableRowsCursorHelper.getCursorFromSequence( | ||
resultsAsArrays(query, resultSequence), | ||
rowSignature | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this logic supposed to be inside
query.getResultRowSignature
;query
already knowscontext()
; why should we tell it from the outside the value ofFinalization
?doesn't that work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should work, but I am scared to make that change given that it will affect everything from native and SQL queries. Lemme try making the change and see if there are any failing tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realised that it shouldn't work. For example - look at GroupByPreShuffleFrameProcessor and GroupByPostShuffleFrameProcessor. The same query requires different finalization modes, since one partially aggregates and we need to intermediate type while the other completely aggregates and finalizes. This information isn't fully captured by the query and needs someone from the outside to tell which finalization mode to use. Therefore we can't trustily determine based on the query context.