You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2023/01/01 08:31:31 UTC
[GitHub] [druid] maytasm opened a new pull request, #13624: Add context to HadoopIngestionSpec
maytasm opened a new pull request, #13624:
URL: https://github.com/apache/druid/pull/13624
Add context to HadoopIngestionSpec
### Description
It is possible to pass `context` to ingestion task using task context (https://druid.apache.org/docs/latest/ingestion/tasks.html#context). However, this context is not added to `HadoopIngestionSpec` and is not accessible further downstream in the various `Jobby`.
Hadoop ingestion job can also be submitted via command line (non-task)(https://druid.apache.org/docs/latest/ingestion/hadoop.html#command-line-non-task-version). This method only takes the `HadoopIngestionSpec` (not the `HadoopIndexTask`). This does not let the user pass context into Hadoop ingestion job.
The fix in this PR is to add `context` map to HadoopIngestionSpec. The `context` map can be set directly in HadoopIngestionSpec if the user is using command line (non-task) version or set in HadoopIndexTask's `context` map which is then automatically added to HadoopIngestionSpec.
Note that if context map is set in both HadoopIngestionSpec and HadoopIndexTask, then the context map in HadoopIndexTask will overwrite the one in HadoopIngestionSpec.
This PR has:
- [x] been self-reviewed.
- [ ] using the [concurrency checklist](https://github.com/apache/druid/blob/master/dev/code-review/concurrency.md) (Remove this item if the PR doesn't have any relation to concurrency.)
- [ ] added documentation for new or modified features or behaviors.
- [ ] a release note entry in the PR description.
- [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
- [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
- [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
- [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
- [ ] added integration tests.
- [x] been tested in a test Druid cluster.
--
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
[GitHub] [druid] abhishekagarwal87 commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1063123778
##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskSerdeTest.java:
##########
@@ -587,4 +587,48 @@
Assert.assertEquals("blah", task.getClasspathPrefix());
Assert.assertEquals("blah", task2.getClasspathPrefix());
}
+
+ @Test
+ public void testHadoopIndexTaskWithContextSerde() throws Exception
+ {
+ final HadoopIndexTask task = new HadoopIndexTask(
+ null,
+ new HadoopIngestionSpec(
+ new DataSchema(
+ "foo", null, new AggregatorFactory[0], new UniformGranularitySpec(
+ Granularities.DAY,
+ null,
+ ImmutableList.of(Intervals.of("2010-01-01/P1D"))
+ ),
+ null,
+ jsonMapper
+ ), new HadoopIOConfig(ImmutableMap.of("paths", "bar"), null, null), null
Review Comment:
@maytasm - can you fix this alert? The changes LGTM otherwise.
--
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
[GitHub] [druid] maytasm commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
maytasm commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1063979686
##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskSerdeTest.java:
##########
@@ -587,4 +587,48 @@
Assert.assertEquals("blah", task.getClasspathPrefix());
Assert.assertEquals("blah", task2.getClasspathPrefix());
}
+
+ @Test
+ public void testHadoopIndexTaskWithContextSerde() throws Exception
+ {
+ final HadoopIndexTask task = new HadoopIndexTask(
+ null,
+ new HadoopIngestionSpec(
+ new DataSchema(
+ "foo", null, new AggregatorFactory[0], new UniformGranularitySpec(
+ Granularities.DAY,
+ null,
+ ImmutableList.of(Intervals.of("2010-01-01/P1D"))
+ ),
+ null,
+ jsonMapper
+ ), new HadoopIOConfig(ImmutableMap.of("paths", "bar"), null, null), null
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
[GitHub] [druid] github-code-scanning[bot] commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1059725518
##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/TaskSerdeTest.java:
##########
@@ -587,4 +587,48 @@
Assert.assertEquals("blah", task.getClasspathPrefix());
Assert.assertEquals("blah", task2.getClasspathPrefix());
}
+
+ @Test
+ public void testHadoopIndexTaskWithContextSerde() throws Exception
+ {
+ final HadoopIndexTask task = new HadoopIndexTask(
+ null,
+ new HadoopIngestionSpec(
+ new DataSchema(
+ "foo", null, new AggregatorFactory[0], new UniformGranularitySpec(
+ Granularities.DAY,
+ null,
+ ImmutableList.of(Intervals.of("2010-01-01/P1D"))
+ ),
+ null,
+ jsonMapper
+ ), new HadoopIOConfig(ImmutableMap.of("paths", "bar"), null, null), null
Review Comment:
## Deprecated method or constructor invocation
Invoking [DataSchema.DataSchema](1) should be avoided because it has been deprecated.
[Show more details](https://github.com/apache/druid/security/code-scanning/3588)
--
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
[GitHub] [druid] samarthjain commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
samarthjain commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1063876902
##########
indexing-hadoop/src/main/java/org/apache/druid/indexer/HadoopIngestionSpec.java:
##########
@@ -69,6 +73,7 @@ public HadoopIngestionSpec(
this.ioConfig = ioConfig;
this.tuningConfig = tuningConfig == null ? HadoopTuningConfig.makeDefaultTuningConfig() : tuningConfig;
this.uniqueId = uniqueId == null ? UUIDUtils.generateUuid() : uniqueId;
+ this.context = context == null ? new HashMap<>() : new HashMap<>(context);
Review Comment:
If context is not passed in, should it be left as `null` or `ImmutableMap.of()`?
--
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
[GitHub] [druid] maytasm merged pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
maytasm merged PR #13624:
URL: https://github.com/apache/druid/pull/13624
--
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
[GitHub] [druid] maytasm commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
maytasm commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1063977492
##########
indexing-hadoop/src/main/java/org/apache/druid/indexer/HadoopIngestionSpec.java:
##########
@@ -69,6 +73,7 @@ public HadoopIngestionSpec(
this.ioConfig = ioConfig;
this.tuningConfig = tuningConfig == null ? HadoopTuningConfig.makeDefaultTuningConfig() : tuningConfig;
this.uniqueId = uniqueId == null ? UUIDUtils.generateUuid() : uniqueId;
+ this.context = context == null ? new HashMap<>() : new HashMap<>(context);
Review Comment:
If the context is not set by the user then we set it to mutable empty hashmap. This allow downstream (internal Druid code) to set the context if needed. For example, in batch ingestion (non-hadoop) even if context is not set by the user, we set it to a mutable empty hashmap. This allow downstream processing to determine contexts like forceTimeChunkLock and set it appropriately to the context map.
--
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
[GitHub] [druid] samarthjain commented on a diff in pull request #13624: Add context to HadoopIngestionSpec
Posted by GitBox <gi...@apache.org>.
samarthjain commented on code in PR #13624:
URL: https://github.com/apache/druid/pull/13624#discussion_r1065231132
##########
indexing-hadoop/src/main/java/org/apache/druid/indexer/HadoopIngestionSpec.java:
##########
@@ -69,6 +73,7 @@ public HadoopIngestionSpec(
this.ioConfig = ioConfig;
this.tuningConfig = tuningConfig == null ? HadoopTuningConfig.makeDefaultTuningConfig() : tuningConfig;
this.uniqueId = uniqueId == null ? UUIDUtils.generateUuid() : uniqueId;
+ this.context = context == null ? new HashMap<>() : new HashMap<>(context);
Review Comment:
@maytasm and I discussed offline and we agreed that to match with other batch ingestion methodologies, context could be set as an empty mutable map.
--
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