public class MergeIntoAction extends TableActionBase
MERGE INTO target-table
USING source-table | source-expr AS source-alias
ON merge-condition
WHEN MATCHED [AND matched-condition]
THEN UPDATE SET xxx
WHEN MATCHED [AND matched-condition]
THEN DELETE
WHEN NOT MATCHED [AND not-matched-condition]
THEN INSERT VALUES (xxx)
WHEN NOT MATCHED BY SOURCE [AND not-matched-by-source-condition]
THEN UPDATE SET xxx
WHEN NOT MATCHED BY SOURCE [AND not-matched-by-source-condition]
THEN DELETE
It builds a query to find the rows to be changed. INNER JOIN with merge-condition is used to find MATCHED rows, and NOT EXISTS with merge-condition is used to find NOT MATCHED rows, then the condition of each action is used to filter the rows.
identifier, table
batchTEnv, catalog, catalogName, catalogOptions, env, flinkCatalog
Constructor and Description |
---|
MergeIntoAction(String warehouse,
String database,
String tableName) |
MergeIntoAction(String warehouse,
String database,
String tableName,
Map<String,String> catalogConfig) |
Modifier and Type | Method and Description |
---|---|
org.apache.flink.streaming.api.datastream.DataStream<org.apache.flink.table.data.RowData> |
buildDataStream() |
void |
run()
The execution method of the action.
|
void |
validate() |
MergeIntoAction |
withMatchedDelete(String matchedDeleteCondition) |
MergeIntoAction |
withMatchedUpsert(String matchedUpsertCondition,
String matchedUpsertSet) |
MergeIntoAction |
withMergeCondition(String mergeCondition) |
MergeIntoAction |
withNotMatchedBySourceDelete(String notMatchedBySourceDeleteCondition) |
MergeIntoAction |
withNotMatchedBySourceUpsert(String notMatchedBySourceUpsertCondition,
String notMatchedBySourceUpsertSet) |
MergeIntoAction |
withNotMatchedInsert(String notMatchedInsertCondition,
String notMatchedInsertValues) |
MergeIntoAction |
withSourceSqls(String... sourceSqls) |
MergeIntoAction |
withSourceTable(String sourceTable) |
MergeIntoAction |
withTargetAlias(String targetAlias) |
batchSink
catalogConfig, catalogLoader, compatibleCheck, execute, initFlinkCatalog, initFlinkEnv, initPaimonCatalog, toPaimonTypes, withStreamExecutionEnvironment
public MergeIntoAction withTargetAlias(String targetAlias)
public MergeIntoAction withSourceTable(String sourceTable)
public MergeIntoAction withSourceSqls(String... sourceSqls)
public MergeIntoAction withMergeCondition(String mergeCondition)
public MergeIntoAction withMatchedUpsert(@Nullable String matchedUpsertCondition, String matchedUpsertSet)
public MergeIntoAction withNotMatchedBySourceUpsert(@Nullable String notMatchedBySourceUpsertCondition, String notMatchedBySourceUpsertSet)
public MergeIntoAction withMatchedDelete(@Nullable String matchedDeleteCondition)
public MergeIntoAction withNotMatchedBySourceDelete(@Nullable String notMatchedBySourceDeleteCondition)
public MergeIntoAction withNotMatchedInsert(@Nullable String notMatchedInsertCondition, String notMatchedInsertValues)
public void validate()
public void run() throws Exception
Action
Exception
public org.apache.flink.streaming.api.datastream.DataStream<org.apache.flink.table.data.RowData> buildDataStream()
Copyright © 2023–2024 The Apache Software Foundation. All rights reserved.