You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "gargvishesh (via GitHub)" <gi...@apache.org> on 2024/08/06 05:52:30 UTC
[PR] Verify idempotent aggregatorFactories in `DataSourceCompactionConfig` and `CompactionTask` (druid)
gargvishesh opened a new pull request, #16846:
URL: https://github.com/apache/druid/pull/16846
This PR adds checks for verification of `DataSourceCompactionConfig` and `CompactionTask` with `msq` engine to ensure:
* each aggregator in `metricsSpec` is idempotent
* `metricsSpec` is non-null when `rollup` is set to `true`
Unit tests and existing compaction ITs have been updated accordingly.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Verify idempotent aggregatorFactories in `DataSourceCompactionConfig` and `CompactionTask` (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1704993205
##########
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java:
##########
@@ -148,6 +148,49 @@ public void testMSQEngineWithRollupFalseWithMetricsSpecIsInvalid()
);
}
+ @Test
+ public void testMSQEngineWithRollupTrueWithoutMetricsSpecIsInvalid()
+ {
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, true),
+ null
+ );
+ CompactionConfigValidationResult validationResult = ClientCompactionRunnerInfo.validateCompactionConfig(
+ compactionConfig,
+ CompactionEngine.NATIVE
+ );
+ Assert.assertFalse(validationResult.isValid());
+ Assert.assertEquals(
+ "MSQ: 'granularitySpec.rollup' must be false if 'metricsSpec' is null",
+ validationResult.getReason()
+ );
+ }
+
+ @Test
+ public void testMSQEngineWithUnsupportedMetricsSpecIsInValid()
+ {
+ // Aggregators having combiningFactory different from the aggregatorFactory are unsupported.
+ final String inputColName = "added";
+ final String outputColName = "sum_added";
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
Review Comment:
Please rename the method `createCompactionConfig` to `createMSQCompactionConfig` to avoid confusion.
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -160,6 +163,10 @@ public static CompactionConfigValidationResult validateRollupForMSQ(
return CompactionConfigValidationResult.failure(
"MSQ: 'granularitySpec.rollup' must be true if 'metricsSpec' is specified"
);
+ } else if (metricsSpec == null && isRollup != null && isRollup) {
Review Comment:
What about empty `metricsSpec`? I guess `rollup` must be false in that case too.
##########
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java:
##########
@@ -148,6 +148,49 @@ public void testMSQEngineWithRollupFalseWithMetricsSpecIsInvalid()
);
}
+ @Test
+ public void testMSQEngineWithRollupTrueWithoutMetricsSpecIsInvalid()
+ {
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, true),
+ null
+ );
+ CompactionConfigValidationResult validationResult = ClientCompactionRunnerInfo.validateCompactionConfig(
+ compactionConfig,
+ CompactionEngine.NATIVE
+ );
+ Assert.assertFalse(validationResult.isValid());
+ Assert.assertEquals(
+ "MSQ: 'granularitySpec.rollup' must be false if 'metricsSpec' is null",
+ validationResult.getReason()
+ );
+ }
+
+ @Test
+ public void testMSQEngineWithUnsupportedMetricsSpecIsInValid()
+ {
+ // Aggregators having combiningFactory different from the aggregatorFactory are unsupported.
+ final String inputColName = "added";
+ final String outputColName = "sum_added";
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, null),
+ new AggregatorFactory[]{new LongSumAggregatorFactory(outputColName, inputColName)}
Review Comment:
Can we add a test for a valid aggregator factory too (unless it already exists)?
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult validateMaxNumTasksForMSQ(Map<Str
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
if (maxNumTasks < 2) {
return CompactionConfigValidationResult.failure(
- "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 1 worker)",
+ "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller + 1 worker)",
maxNumTasks
);
}
}
return CompactionConfigValidationResult.success();
}
+
+ /**
+ * Validate each metric is idempotent, i.e. it defines some aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+ */
+ public static CompactionConfigValidationResult validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+ {
+ if (metricsSpec == null) {
+ return CompactionConfigValidationResult.success();
+ }
+ return Arrays.stream(metricsSpec)
+ .filter(aggregatorFactory ->
+ !aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))
+ .findFirst()
+ .map(aggregatorFactory ->
+ CompactionConfigValidationResult.failure(
+ "MSQ: Non-idempotent aggregator[%s] not supported in 'metricsSpec'.",
+ aggregatorFactory.getName()
+ )).orElse(CompactionConfigValidationResult.success());
Review Comment:
Style: the `orElse` should align with the `map`
```suggestion
.map(
aggregatorFactory ->
CompactionConfigValidationResult.failure(
"MSQ: Non-idempotent aggregator[%s] not supported in 'metricsSpec'.",
aggregatorFactory.getName()
)
).orElse(CompactionConfigValidationResult.success());
```
##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/indexing/MSQCompactionRunnerTest.java:
##########
@@ -345,48 +377,6 @@ public void testMSQControllerTaskSpecWithAggregatorsIsValid() throws JsonProcess
Assert.assertEquals(WorkerAssignmentStrategy.MAX, actualMSQSpec.getAssignmentStrategy());
}
- @Test
- public void testIntervalsWithRolledUpSegmentsAndNonIdempotentAggregatorFails()
Review Comment:
Shouldn't we still have this test i.e. a non idempotent aggregator should continue to fail, right?
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult validateMaxNumTasksForMSQ(Map<Str
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
if (maxNumTasks < 2) {
return CompactionConfigValidationResult.failure(
- "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 1 worker)",
+ "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller + 1 worker)",
maxNumTasks
);
}
}
return CompactionConfigValidationResult.success();
}
+
+ /**
+ * Validate each metric is idempotent, i.e. it defines some aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+ */
+ public static CompactionConfigValidationResult validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+ {
+ if (metricsSpec == null) {
+ return CompactionConfigValidationResult.success();
+ }
+ return Arrays.stream(metricsSpec)
+ .filter(aggregatorFactory ->
+ !aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))
Review Comment:
Nit: can be in a single line
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "gargvishesh (via GitHub)" <gi...@apache.org>.
gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705027898
##########
extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/indexing/MSQCompactionRunnerTest.java:
##########
@@ -345,48 +377,6 @@ public void testMSQControllerTaskSpecWithAggregatorsIsValid() throws JsonProcess
Assert.assertEquals(WorkerAssignmentStrategy.MAX, actualMSQSpec.getAssignmentStrategy());
}
- @Test
- public void testIntervalsWithRolledUpSegmentsAndNonIdempotentAggregatorFails()
Review Comment:
There is already a test `testMSQEngineWithUnsupportedMetricsSpecIsInValid` which checks that.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "gargvishesh (via GitHub)" <gi...@apache.org>.
gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705065027
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult validateMaxNumTasksForMSQ(Map<Str
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
if (maxNumTasks < 2) {
return CompactionConfigValidationResult.failure(
- "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 1 worker)",
+ "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller + 1 worker)",
maxNumTasks
);
}
}
return CompactionConfigValidationResult.success();
}
+
+ /**
+ * Validate each metric is idempotent, i.e. it defines some aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+ */
+ public static CompactionConfigValidationResult validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+ {
+ if (metricsSpec == null) {
+ return CompactionConfigValidationResult.success();
+ }
+ return Arrays.stream(metricsSpec)
+ .filter(aggregatorFactory ->
+ !aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))
+ .findFirst()
+ .map(aggregatorFactory ->
+ CompactionConfigValidationResult.failure(
+ "MSQ: Non-idempotent aggregator[%s] not supported in 'metricsSpec'.",
+ aggregatorFactory.getName()
+ )).orElse(CompactionConfigValidationResult.success());
Review Comment:
Updated.
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -174,11 +181,30 @@ public static CompactionConfigValidationResult validateMaxNumTasksForMSQ(Map<Str
.getInt(ClientMSQContext.CTX_MAX_NUM_TASKS, ClientMSQContext.DEFAULT_MAX_NUM_TASKS);
if (maxNumTasks < 2) {
return CompactionConfigValidationResult.failure(
- "MSQ: Context maxNumTasks[%,d] must be at least 2 (1 controller + 1 worker)",
+ "MSQ: Context 'maxNumTasks'[%,d] must be at least 2 (1 controller + 1 worker)",
maxNumTasks
);
}
}
return CompactionConfigValidationResult.success();
}
+
+ /**
+ * Validate each metric is idempotent, i.e. it defines some aggregatorFactory 'A' s.t. 'A = A.combiningFactory()'.
+ */
+ public static CompactionConfigValidationResult validateMetricsSpecForMSQ(AggregatorFactory[] metricsSpec)
+ {
+ if (metricsSpec == null) {
+ return CompactionConfigValidationResult.success();
+ }
+ return Arrays.stream(metricsSpec)
+ .filter(aggregatorFactory ->
+ !aggregatorFactory.equals(aggregatorFactory.getCombiningFactory()))
Review Comment:
Updated.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "gargvishesh (via GitHub)" <gi...@apache.org>.
gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705064195
##########
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java:
##########
@@ -148,6 +148,49 @@ public void testMSQEngineWithRollupFalseWithMetricsSpecIsInvalid()
);
}
+ @Test
+ public void testMSQEngineWithRollupTrueWithoutMetricsSpecIsInvalid()
+ {
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, true),
+ null
+ );
+ CompactionConfigValidationResult validationResult = ClientCompactionRunnerInfo.validateCompactionConfig(
+ compactionConfig,
+ CompactionEngine.NATIVE
+ );
+ Assert.assertFalse(validationResult.isValid());
+ Assert.assertEquals(
+ "MSQ: 'granularitySpec.rollup' must be false if 'metricsSpec' is null",
+ validationResult.getReason()
+ );
+ }
+
+ @Test
+ public void testMSQEngineWithUnsupportedMetricsSpecIsInValid()
+ {
+ // Aggregators having combiningFactory different from the aggregatorFactory are unsupported.
+ final String inputColName = "added";
+ final String outputColName = "sum_added";
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
Review Comment:
Done
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "gargvishesh (via GitHub)" <gi...@apache.org>.
gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705031129
##########
server/src/test/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfoTest.java:
##########
@@ -148,6 +148,49 @@ public void testMSQEngineWithRollupFalseWithMetricsSpecIsInvalid()
);
}
+ @Test
+ public void testMSQEngineWithRollupTrueWithoutMetricsSpecIsInvalid()
+ {
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, true),
+ null
+ );
+ CompactionConfigValidationResult validationResult = ClientCompactionRunnerInfo.validateCompactionConfig(
+ compactionConfig,
+ CompactionEngine.NATIVE
+ );
+ Assert.assertFalse(validationResult.isValid());
+ Assert.assertEquals(
+ "MSQ: 'granularitySpec.rollup' must be false if 'metricsSpec' is null",
+ validationResult.getReason()
+ );
+ }
+
+ @Test
+ public void testMSQEngineWithUnsupportedMetricsSpecIsInValid()
+ {
+ // Aggregators having combiningFactory different from the aggregatorFactory are unsupported.
+ final String inputColName = "added";
+ final String outputColName = "sum_added";
+ DataSourceCompactionConfig compactionConfig = createCompactionConfig(
+ new DynamicPartitionsSpec(3, null),
+ Collections.emptyMap(),
+ new UserCompactionTaskGranularityConfig(null, null, null),
+ new AggregatorFactory[]{new LongSumAggregatorFactory(outputColName, inputColName)}
Review Comment:
It is covered in `testMSQEngineWithRollupNullWithMetricsSpecIsValid`
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on PR #16846:
URL: https://github.com/apache/druid/pull/16846#issuecomment-2270518720
Updated title to reflect impact on user behaviour.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 merged PR #16846:
URL: https://github.com/apache/druid/pull/16846
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org
Re: [PR] Do not support non-idempotent aggregator in MSQ compaction (druid)
Posted by "gargvishesh (via GitHub)" <gi...@apache.org>.
gargvishesh commented on code in PR #16846:
URL: https://github.com/apache/druid/pull/16846#discussion_r1705067994
##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -160,6 +163,10 @@ public static CompactionConfigValidationResult validateRollupForMSQ(
return CompactionConfigValidationResult.failure(
"MSQ: 'granularitySpec.rollup' must be true if 'metricsSpec' is specified"
);
+ } else if (metricsSpec == null && isRollup != null && isRollup) {
Review Comment:
Thanks. Added to the check.
--
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org