jihoonson commented on a change in pull request #10387:
URL: https://github.com/apache/druid/pull/10387#discussion_r487371767



##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit

Review comment:
       I think this is good to document in the class-level Javadoc. Would you 
please add a description for overall behavior?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.

Review comment:
       Hmm, should it override `isSplittable()` and return true only when all 
underlying inputSources are splittable?

##########
File path: 
core/src/main/java/org/apache/druid/data/input/impl/CombiningInputSource.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.data.input.impl;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import org.apache.druid.data.input.AbstractInputSource;
+import org.apache.druid.data.input.InputFormat;
+import org.apache.druid.data.input.InputSource;
+import org.apache.druid.data.input.InputSplit;
+import org.apache.druid.data.input.SplitHintSpec;
+import org.apache.druid.java.util.common.Pair;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+/**
+ * InputSource that combines data from multiple inputSources. The delegate 
inputSources must be splittable.
+ */
+
+public class CombiningInputSource extends AbstractInputSource implements 
SplittableInputSource
+{
+  private final List<SplittableInputSource> delegates;
+
+  @JsonCreator
+  public CombiningInputSource(
+      @JsonProperty("delegates") List<SplittableInputSource> delegates
+  )
+  {
+    Preconditions.checkArgument(
+        delegates != null && !delegates.isEmpty(),
+        "Must specify atleast one delegate inputSource"
+    );
+    this.delegates = delegates;
+  }
+
+  @JsonProperty
+  public List<SplittableInputSource> getDelegates()
+  {
+    return delegates;
+  }
+
+  @Override
+  public Stream<InputSplit> createSplits(
+      InputFormat inputFormat,
+      @Nullable SplitHintSpec splitHintSpec
+  )
+  {
+    return delegates.stream().flatMap(inputSource -> {
+      try {
+        // Each inputSplit is paired up with its respective inputSource so 
that during split, withSplit() is called against
+        // the correct inputSource for each inputSplit
+        return inputSource.createSplits(inputFormat, splitHintSpec)
+                          .map(inputsplit -> new 
InputSplit(Pair.of(inputSource, inputsplit)));
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    });
+  }
+
+  @Override
+  public int estimateNumSplits(InputFormat inputFormat, @Nullable 
SplitHintSpec splitHintSpec)
+  {
+    return delegates.stream().mapToInt(inputSource -> {
+      try {
+        return inputSource.estimateNumSplits(inputFormat, splitHintSpec);
+      }
+      catch (IOException e) {
+        throw new RuntimeException(e);
+      }
+    }).sum();
+  }
+
+  @Override
+  public InputSource withSplit(InputSplit split)
+  {
+    Pair<SplittableInputSource, InputSplit> inputSourceWithSplit = (Pair) 
split.get();
+    return inputSourceWithSplit.lhs.withSplit(inputSourceWithSplit.rhs);
+  }
+
+  @Override
+  public boolean needsFormat()
+  {
+    // This is called only when ParallelIndexIngestionSpec needs to decide if 
either inputformat vs parserspec is required.
+    // So if atleast one of the delegate inputSources needsFormat, we set this 
to true.

Review comment:
       typo: at least

##########
File path: docs/ingestion/native-batch.md
##########
@@ -1368,6 +1368,48 @@ Compared to the other native batch InputSources, SQL 
InputSource behaves differe
 * Similar to file-based input formats, any updates to existing data will 
replace the data in segments specific to the intervals specified in the 
`granularitySpec`.
 
 
+### Combining Input Source
+
+The Combining input source is used to read data from multiple InputSources. 
This input source should be only used if all the delegate input sources are
+ _splittable_ and can be used by the [Parallel task](#parallel-task). This 
input source will identify the splits from its delegates and each split will be 
processed by a worker task. Similar to other input sources, this input source 
supports a single `inputFormat`. Therefore, please note that delegate input 
sources requiring an `inputFormat` must have the same format for input data.

Review comment:
       > please note that delegate input sources requiring an `inputFormat` 
must have the same format for input data.
   
   Hmm, thinking about this requirement, could it be more useful if you can 
read multiple inputSources even when they are formatted differently? 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to