1
0

[HUDI-1860] Add INSERT_OVERWRITE and INSERT_OVERWRITE_TABLE support to DeltaStreamer (#3184)

This commit is contained in:
Samrat
2021-07-20 07:19:43 +05:30
committed by GitHub
parent d5026e9a24
commit a086d255c8
8 changed files with 166 additions and 6 deletions

View File

@@ -53,6 +53,16 @@ public class HoodieDeltaStreamerWrapper extends HoodieDeltaStreamer {
return upsert(WriteOperationType.BULK_INSERT);
}
public JavaRDD<WriteStatus> insertOverwrite() throws
Exception {
return upsert(WriteOperationType.INSERT_OVERWRITE);
}
public JavaRDD<WriteStatus> insertOverwriteTable() throws
Exception {
return upsert(WriteOperationType.INSERT_OVERWRITE_TABLE);
}
public void scheduleCompact() throws Exception {
// Since we don't support scheduleCompact() operation in delta-streamer, assume upsert without any data that will
// trigger scheduling compaction

View File

@@ -163,6 +163,26 @@ public class HoodieTestSuiteWriter implements Serializable {
}
}
public JavaRDD<WriteStatus> insertOverwrite(Option<String> instantTime) throws Exception {
if(cfg.useDeltaStreamer){
return deltaStreamerWrapper.insertOverwrite();
} else {
Pair<SchemaProvider, Pair<String, JavaRDD<HoodieRecord>>> nextBatch = fetchSource();
lastCheckpoint = Option.of(nextBatch.getValue().getLeft());
return writeClient.insertOverwrite(nextBatch.getRight().getRight(), instantTime.get()).getWriteStatuses();
}
}
public JavaRDD<WriteStatus> insertOverwriteTable(Option<String> instantTime) throws Exception {
if(cfg.useDeltaStreamer){
return deltaStreamerWrapper.insertOverwriteTable();
} else {
Pair<SchemaProvider, Pair<String, JavaRDD<HoodieRecord>>> nextBatch = fetchSource();
lastCheckpoint = Option.of(nextBatch.getValue().getLeft());
return writeClient.insertOverwriteTable(nextBatch.getRight().getRight(), instantTime.get()).getWriteStatuses();
}
}
public JavaRDD<WriteStatus> bulkInsert(Option<String> instantTime) throws Exception {
if (cfg.useDeltaStreamer) {
return deltaStreamerWrapper.bulkInsert();

View File

@@ -0,0 +1,40 @@
/*
* 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.hudi.integ.testsuite.dag.nodes;
import org.apache.hudi.client.WriteStatus;
import org.apache.hudi.common.util.Option;
import org.apache.hudi.integ.testsuite.HoodieTestSuiteWriter;
import org.apache.hudi.integ.testsuite.configuration.DeltaConfig.Config;
import org.apache.spark.api.java.JavaRDD;
public class InsertOverwriteNode extends InsertNode {
public InsertOverwriteNode(Config config) {
super(config);
}
@Override
protected JavaRDD<WriteStatus> ingest(HoodieTestSuiteWriter hoodieTestSuiteWriter,
Option<String> commitTime)
throws Exception {
log.info("Execute insert overwrite node {}", this.getName());
return hoodieTestSuiteWriter.insertOverwrite(commitTime);
}
}

View File

@@ -0,0 +1,40 @@
/*
* 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.hudi.integ.testsuite.dag.nodes;
import org.apache.hudi.client.WriteStatus;
import org.apache.hudi.common.util.Option;
import org.apache.hudi.integ.testsuite.HoodieTestSuiteWriter;
import org.apache.hudi.integ.testsuite.configuration.DeltaConfig.Config;
import org.apache.spark.api.java.JavaRDD;
public class InsertOverwriteTableNode extends InsertNode {
public InsertOverwriteTableNode(Config config) {
super(config);
}
@Override
protected JavaRDD<WriteStatus> ingest(HoodieTestSuiteWriter hoodieTestSuiteWriter,
Option<String> commitTime)
throws Exception {
log.info("Execute insert overwrite table node {}", this.getName());
return hoodieTestSuiteWriter.insertOverwriteTable(commitTime);
}
}