Skip to content

Commit e9e2391

Browse files
authored
Merge pull request #1443 from cloudsufi/patch/empty-input-format
[PLUGIN-1742] Add GCSEmptyInputFormat (Allow Empty Input)
2 parents e434a72 + 4fe66b7 commit e9e2391

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright © 2024 Cask Data, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5+
* use this file except in compliance with the License. You may obtain a copy of
6+
* the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations under
14+
* the License.
15+
*
16+
*/
17+
18+
package io.cdap.plugin.gcp.common;
19+
20+
import io.cdap.plugin.format.input.AbstractEmptyInputFormat;
21+
22+
23+
/**
24+
* An InputFormat that returns no data.
25+
* @param <K> the type of key
26+
* @param <V> the type of value
27+
*/
28+
public class GCSEmptyInputFormat<K, V> extends AbstractEmptyInputFormat<K, V> {
29+
// no-op
30+
}

src/main/java/io/cdap/plugin/gcp/gcs/source/GCSSource.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import io.cdap.plugin.format.plugin.FileSourceProperties;
4444
import io.cdap.plugin.gcp.common.GCPConnectorConfig;
4545
import io.cdap.plugin.gcp.common.GCPUtils;
46+
import io.cdap.plugin.gcp.common.GCSEmptyInputFormat;
4647
import io.cdap.plugin.gcp.crypto.EncryptedFileSystem;
4748
import io.cdap.plugin.gcp.gcs.GCSPath;
4849
import io.cdap.plugin.gcp.gcs.connector.GCSConnector;
@@ -77,6 +78,11 @@ public void configurePipeline(PipelineConfigurer pipelineConfigurer) {
7778
super.configurePipeline(pipelineConfigurer);
7879
}
7980

81+
@Override
82+
protected String getEmptyInputFormatClassName() {
83+
return GCSEmptyInputFormat.class.getName();
84+
}
85+
8086
@Override
8187
public void prepareRun(BatchSourceContext context) throws Exception {
8288
// Get location of the source for lineage
@@ -268,11 +274,6 @@ public Long getMinSplitSize() {
268274
return minSplitSize;
269275
}
270276

271-
@Override
272-
public boolean shouldAllowEmptyInput() {
273-
return false;
274-
}
275-
276277
public boolean isCopyHeader() {
277278
return shouldCopyHeader();
278279
}

0 commit comments

Comments
 (0)