You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the finalizingResults is same as subqueryResult, because subquery.context().isFinalize(false) == false, Why is finalize equal to false?
Because it was overwritten as false in the FinalizeResultsQueryRunner.java.
public Sequence<T> run(final QueryPlus<T> queryPlus, ResponseContext responseContext)
{
final Query<T> query = queryPlus.getQuery();
final QueryContext queryContext = query.context();
final boolean isBySegment = queryContext.isBySegment();
final boolean shouldFinalize = queryContext.isFinalize(true);
final Query<T> queryToRun;
final Function<T, ?> finalizerFn;
final MetricManipulationFn metricManipulationFn;
if (shouldFinalize) {
# ****************
# overridden here
queryToRun = query.withOverriddenContext(ImmutableMap.of(QueryContexts.FINALIZE_KEY, false));
metricManipulationFn = MetricManipulatorFns.finalizing();
} else {
queryToRun = query;
metricManipulationFn = MetricManipulatorFns.identity();
}
So when processing subQuery result in spillingGrouper, status cannot be parsed as a number: currentValue is: Pair{lhs=1735012987483, rhs=1}, (expected current value is 1, after LongLastAggregator finalize) the return result is: NullHandling.defaultLongValue()=0
private Number getCurrentValueAsNumber()
{
final Object currentValue = getCurrentValue();
if (currentValue instanceof StructuredData) {
return Rows.objectToNumber(columnName, ((StructuredData) currentValue).getValue(), throwParseExceptions);
}
return Rows.objectToNumber(
columnName,
currentValue,
throwParseExceptions
);
}
My Solution
How to solve this problem? I think when sub query can be performed, finalize needs to be set to true. My solution as follows:
FinalizeResultsQueryRunner.java
private Sequence<ResultRow> mergeGroupByResultsWithoutPushDown(
GroupByQuery query,
GroupByQueryResources resource,
QueryRunner<ResultRow> runner,
ResponseContext context
)
{
// If there's a subquery, merge subquery results and then apply the aggregator
final DataSource dataSource = query.getDataSource();
if (dataSource instanceof QueryDataSource) {
final GroupByQuery subquery;
try {
// Inject outer query context keys into subquery if they don't already exist in the subquery context.
// Unlike withOverriddenContext's normal behavior, we want keys present in the subquery to win.
final Map<String, Object> subqueryContext = new TreeMap<>();
if (query.getContext() != null) {
for (Map.Entry<String, Object> entry : query.getContext().entrySet()) {
if (entry.getValue() != null) {
subqueryContext.put(entry.getKey(), entry.getValue());
}
}
}
if (((QueryDataSource) dataSource).getQuery().getContext() != null) {
subqueryContext.putAll(((QueryDataSource) dataSource).getQuery().getContext());
}
subqueryContext.put(GroupByQuery.CTX_KEY_SORT_BY_DIMS_FIRST, false);
# my solution:
# if can perform subquery, the finalize is should be set to true
if (canPerformSubquery(((QueryDataSource) dataSource).getQuery())) {
subqueryContext.put(QueryContexts.FINALIZE_KEY, true);
}
subquery = (GroupByQuery) ((QueryDataSource) dataSource).getQuery().withOverriddenContext(subqueryContext);
}
catch (ClassCastException e) {
throw new UnsupportedOperationException("Subqueries must be of type 'group by'");
}
final Sequence<ResultRow> subqueryResult = mergeGroupByResults(
subquery,
resource,
runner,
context
);
final Sequence<ResultRow> finalizingResults = finalizeSubqueryResults(subqueryResult, subquery);
The text was updated successfully, but these errors were encountered:
@kfaraz@gianm@abhishekagarwal87 Could someone give me some ideas to solve this problem? The solution I presented is problematic in certain scenarios because 50 of the test cases did not pass
Broker errors when processing the groupBy subquery.
Affected Version
Apache Druid 28.0.1
Description
Please include as much detailed information about the problem as possible.
3 nodes in cluster.
NA.
subQuery result:
So when using the longSum operator to aggregate subquery results, the expected result should be:
but actual result is:
GroupByQueryQueryToolChest.java
method: mergeGroupByResultsWithoutPushDown, line: 224 -250
the subqueryResult is :
the finalizingResults is same as subqueryResult, because subquery.context().isFinalize(false) == false, Why is finalize equal to false?
Because it was overwritten as false in the FinalizeResultsQueryRunner.java.
FinalizeResultsQueryRunner.java
method: run, line: 58-75
So when processing subQuery result in spillingGrouper,
status
cannot be parsed as a number:currentValue is: Pair{lhs=1735012987483, rhs=1}, (expected current value is 1, after LongLastAggregator finalize)
the return result is: NullHandling.defaultLongValue()=0
How to solve this problem? I think when sub query can be performed, finalize needs to be set to true. My solution as follows:
FinalizeResultsQueryRunner.java
The text was updated successfully, but these errors were encountered: