This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/dev/pr-13245-af0af664ab7da9b637b1de7cadf4d7b6c64e08a6 in repository https://gitbox.apache.org/repos/asf/seatunnel.git
commit b537b9046ec272bc1838f5ea5807fa87241dcc82 Author: Goutam Adwant <[email protected]> AuthorDate: Thu Nov 26 13:44:34 2026 +0000 [Fix][Connector-V2][HBase] Apply DELETE rows and flush the client buffer at checkpoint (#13245) --- docs/en/connectors/sink/Hbase.md | 23 ++ .../introduction/concepts/incompatible-changes.md | 17 ++ docs/zh/connectors/sink/Hbase.md | 4 + .../introduction/concepts/incompatible-changes.md | 8 + .../seatunnel/hbase/client/HbaseClient.java | 53 +++- .../seatunnel/hbase/sink/HbaseSinkWriter.java | 148 +++++++++-- .../seatunnel/hbase/client/HbaseClientTest.java | 36 ++- .../seatunnel/hbase/sink/HbaseSinkWriterTest.java | 277 ++++++++++++++++++++- .../hbase/sink/HbaseSinkWriterTypeConvertTest.java | 3 +- .../seatunnel/e2e/connector/hbase/HbaseIT.java | 60 +++++ .../resources/fake-to-hbase-with-cdc-rows.conf | 56 +++++ .../fake-to-hbase-with-key-only-delete.conf | 47 ++++ 12 files changed, 697 insertions(+), 35 deletions(-) diff --git a/docs/en/connectors/sink/Hbase.md b/docs/en/connectors/sink/Hbase.md index ebac58dbb7..bf0fe008a6 100644 --- a/docs/en/connectors/sink/Hbase.md +++ b/docs/en/connectors/sink/Hbase.md @@ -19,6 +19,7 @@ how null values, row keys, WAL, timestamps, and existing data are handled. ## Key features - [ ] [exactly-once](../../introduction/concepts/connector-v2-features.md) +- [x] [cdc](../../introduction/concepts/connector-v2-features.md) - [x] [support multiple table write](../../introduction/concepts/connector-v2-features.md) - [ ] [timer flush](../../introduction/concepts/connector-v2-features.md) @@ -146,6 +147,28 @@ Sink plugin common parameters, please refer to [Sink Common Options](../common-o per-field mappings when fields should go to different column families. - `schema_save_mode` controls table creation or recreation. `data_save_mode` controls whether existing rows are kept, dropped, or treated as an error. +- Change data capture rows are applied by row key: `INSERT` and `UPDATE_AFTER` rows are written as + a `Put`, a `DELETE` row deletes the column families this sink writes to for that row key (other + families of the table are left alone). A projection of only row-key and version columns has no + mapped family, so the sink rejects DELETE rows. Include a payload column for the family you + intend to delete. `UPDATE_BEFORE` is ignored. The sink does not pair + before/after images, which can reach different replicas or checkpoints. If a row-key column + changes, send an explicit `DELETE` for the old key and an `INSERT` for the new key upstream. + With `null_mode = skip` (the default), an update that sets a column to null keeps the old cell; + use `null_mode = empty` to overwrite it. +- Mutations are stamped with the `version_column` value when it is set, otherwise with the current + time. `version_column` must hold epoch milliseconds: a delete hides every version up to its + timestamp, so a value far in the future hides later writes to that row key until it is + compacted away. Without `version_column`, a `DELETE` and an `INSERT` of the same row key in the + same millisecond resolve to the delete, so set `version_column` for change data capture sources. +- With the default HBase client configuration, each checkpoint flushes the pending mutations from + `write_buffer_size` and waits for the region servers to accept them. If the client reports a + failed drain during a write or checkpoint, the writer rejects further writes and checkpoints + because some buffered rows may have been lost. Keep the HBase client periodic flush disabled + (`hbase.client.write.buffer.periodicflush.timeout.ms = 0`) if the job relies on this checkpoint + behavior. A native client timer can drain rows independently of the checkpoint and only log + its own failures. With `wal_write = false` (the default), accepted rows can still be lost in a + region server crash. ## Example diff --git a/docs/en/introduction/concepts/incompatible-changes.md b/docs/en/introduction/concepts/incompatible-changes.md index 0a19766974..c8cf50ac61 100644 --- a/docs/en/introduction/concepts/incompatible-changes.md +++ b/docs/en/introduction/concepts/incompatible-changes.md @@ -5,6 +5,23 @@ You need to check this document before you upgrade to related version. ## dev +### HBase sink: DELETE rows remove mapped data + +`DELETE` rows now remove all cell versions up to the mutation timestamp in the column families +mapped by this sink. Previously these rows were written as Put mutations of the old values. +Unmapped families remain intact. If the sink projects only row-key and version columns, it +rejects DELETE rows because no family is mapped. Include a payload column for the family you +intend to delete. +Jobs that need the previous append-only behavior must filter DELETE rows before the sink. +`UPDATE_BEFORE` rows are now ignored instead of written as Put mutations. Key-changing updates +require explicit old-key DELETE/new-key +INSERT events upstream. Use `version_column` to supply correctly ordered timestamps: an equal- or +older-timestamp Put cannot override a delete tombstone. Checkpoint flushes wait for region-server +acceptance when the HBase client periodic flush is disabled (the default). Keep it disabled when +relying on checkpoint flushes. `wal_write = false` still does not protect against a region-server +crash. +No configuration or checkpoint-format migration is required. + ### MongoDB sink: omitted buffer and retry options now use their documented defaults - **Behavior change: a non-transactional MongoDB sink without `buffer-flush.*` or `retry.*` options writes in batches and retries failed writes** diff --git a/docs/zh/connectors/sink/Hbase.md b/docs/zh/connectors/sink/Hbase.md index 0f75b4b15a..56f90b7e22 100644 --- a/docs/zh/connectors/sink/Hbase.md +++ b/docs/zh/connectors/sink/Hbase.md @@ -17,6 +17,7 @@ import ChangeLog from '../changelog/connector-hbase.md'; ## 主要特性 - [ ] [精确一次](../../introduction/concepts/connector-v2-features.md) +- [x] [cdc](../../introduction/concepts/connector-v2-features.md) - [x] [支持多表写入](../../introduction/concepts/connector-v2-features.md) - [ ] [定时刷新](../../introduction/concepts/connector-v2-features.md) @@ -139,6 +140,9 @@ Sink 插件常用参数,详见 Sink 常用选项 [Sink Common Options](../comm - `table = "${table_name}"` 会把每张上游表写入同名 HBase 表,也可以和固定文本组合,例如 `ods_${table_name}`。 - `family_name { all_columns = "info" }` 会把所有非 rowkey 字段写入同一个列簇。不同字段需要写入不同列簇时,请使用逐字段映射。 - `schema_save_mode` 控制是否创建或重建表,`data_save_mode` 控制保留、清空已有数据,还是在已有数据存在时报错。 +- 变更数据按 rowkey 写入:`INSERT` 和 `UPDATE_AFTER` 行写为 `Put`,`DELETE` 行删除该 rowkey 下本 sink 写入的列簇(表中其他列簇不受影响)。如果只投影 rowkey 和版本列,则没有映射列簇,sink 会拒绝 DELETE 行。请在投影中包含目标列簇的至少一个数据列。`UPDATE_BEFORE` 被忽略。前后镜像可能经过不同副本或 checkpoint,因此 sink 不对它们配对。rowkey 列发生变化时,上游应显式发送旧键的 `DELETE` 和新键的 `INSERT`。`null_mode = skip`(默认值)时,把某列更新为 null 会保留旧值,需要覆盖请使用 `null_mode = empty`。 +- 设置了 `version_column` 时,写入和删除都使用它的值作为时间戳,否则使用当前时间。`version_column` 必须是毫秒级 epoch 时间戳:删除会隐藏该时间戳之前的所有版本,远在未来的值会在 compaction 之前一直隐藏该 rowkey 的后续写入。未设置 `version_column` 时,同一毫秒内对同一 rowkey 的 `DELETE` 和 `INSERT` 会以删除为准,因此变更数据源建议设置 `version_column`。 +- 默认配置下,checkpoint 会刷新 HBase 客户端缓冲区(`write_buffer_size`),等待 region server 接受数据。如果写入或 checkpoint 时客户端报告缓冲区刷新失败,writer 会拒绝后续写入和 checkpoint,因为缓冲的数据可能已经丢失。依赖此 checkpoint 行为的作业应保持 HBase 客户端定时刷新关闭(`hbase.client.write.buffer.periodicflush.timeout.ms = 0`)。客户端定时器可独立于 checkpoint 刷新,并且可能只记录自己的失败。`wal_write = false`(默认值)时,region server 崩溃仍可能导致已接受的数据丢失。 ## 案例 diff --git a/docs/zh/introduction/concepts/incompatible-changes.md b/docs/zh/introduction/concepts/incompatible-changes.md index 78719c9717..f036b66679 100644 --- a/docs/zh/introduction/concepts/incompatible-changes.md +++ b/docs/zh/introduction/concepts/incompatible-changes.md @@ -4,6 +4,14 @@ ## dev +### HBase sink:DELETE 行删除映射的数据 + +`DELETE` 行现在会删除本 sink 映射列簇中不晚于该变更时间戳的所有单元格版本。此前这些行会将旧值作为 Put 写入,未映射列簇仍不受影响。仅投影 rowkey 和版本列时,没有映射列簇,sink 会拒绝 DELETE 行。请在投影中包含目标列簇的至少一个数据列。 +需要原先仅追加行为的作业应在 sink 前过滤 DELETE 行。`UPDATE_BEFORE` 行现在会被忽略,不再作为 Put 写入。修改 rowkey 时需要上游显式发送旧键 DELETE 和新键 INSERT。 +使用 `version_column` 提供正确排序的时间戳:相同或更早时间戳的 Put 无法覆盖删除标记。 +关闭 HBase 客户端定时刷新(默认行为)时,checkpoint 刷新会等待 region server 接受数据。依赖 checkpoint 刷新的作业应保持定时刷新关闭。`wal_write = false` 仍不能防止 region server 崩溃导致的数据丢失。 +无需迁移配置或 checkpoint 格式。 + ### MongoDB Sink:未配置的缓冲与重试选项使用文档中的默认值 - **行为变更:未设置 `buffer-flush.*` 或 `retry.*` 选项的非事务 MongoDB Sink 会按批写入,并重试失败的写入** diff --git a/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java b/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java index 64a5cbb102..9d27b7d0da 100644 --- a/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java +++ b/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java @@ -35,7 +35,9 @@ import org.apache.hadoop.hbase.client.BufferedMutatorParams; import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.ConnectionFactory; +import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.HTable; +import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.RegionLocator; import org.apache.hadoop.hbase.client.Result; @@ -326,32 +328,59 @@ public class HbaseClient { } } - /** Close Hbase connection. */ + /** + * Flush and close the mutator, then the admin and the connection. A failure in one step is + * logged and the remaining resources are still released. + */ public void close() { - try { - if (hbaseMutator != null) { - hbaseMutator.flush(); + if (hbaseMutator != null) { + try { hbaseMutator.close(); + } catch (IOException e) { + log.error("Close Hbase mutator failed.", e); } - if (admin != null) { + } + if (admin != null) { + try { admin.close(); + } catch (IOException e) { + log.error("Close Hbase admin failed.", e); } - if (connection != null) { + } + if (connection != null) { + try { connection.close(); + } catch (IOException e) { + log.error("Close Hbase connection failed.", e); } - } catch (IOException e) { - log.error("Close Hbase connection failed.", e); } } + /** Retains the Put entry point for callers compiled before general mutation support. */ + public void mutate(Put put) throws IOException { + mutate((Mutation) put); + } + /** - * Mutate a Put. + * Buffer a mutation (a {@link Put} or a {@link Delete}) in the client's {@link + * BufferedMutator}. The mutation reaches the region server when the buffer fills up or on + * {@link #flush()}. * - * @param put Hbase put + * @param mutation Hbase mutation * @throws IOException exception */ - public void mutate(Put put) throws IOException { - hbaseMutator.mutate(put); + public void mutate(Mutation mutation) throws IOException { + hbaseMutator.mutate(mutation); + } + + /** + * Send every buffered mutation to the region servers and wait for them to be applied. A + * mutation that failed with retries exhausted is reported here. + * + * @throws IOException exception + */ + public void flush() throws IOException { + hbaseMutator.flush(); } /** diff --git a/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriter.java b/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriter.java index f8d5286a35..beb6915788 100644 --- a/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriter.java +++ b/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriter.java @@ -34,7 +34,9 @@ import org.apache.seatunnel.connectors.seatunnel.hbase.state.HbaseCommitInfo; import org.apache.seatunnel.connectors.seatunnel.hbase.state.HbaseSinkState; import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.client.Delete; import org.apache.hadoop.hbase.client.Durability; +import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.util.Bytes; @@ -46,7 +48,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; -import java.util.Map; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -71,6 +72,15 @@ public class HbaseSinkWriter private String defaultFamilyName = "value"; + /** Column families this writer puts data into; a DELETE row only touches these. */ + private final List<byte[]> writtenFamilies; + + /** + * Retains the first client failure that may have discarded buffered mutations. Both mutate and + * flush can drain the buffer, so neither may be retried on this writer after that failure. + */ + private IOException bufferedWriteFailure; + public HbaseSinkWriter( SeaTunnelRowType seaTunnelRowType, HbaseParameters hbaseParameters, @@ -95,6 +105,13 @@ public class HbaseSinkWriter defaultFamilyName = hbaseParameters.getFamilyNames().getOrDefault(ALL_COLUMNS, defaultFamilyName); } + this.writtenFamilies = + writeColumnIndexes(seaTunnelRowType.getTotalFields()).stream() + .map(seaTunnelRowType::getFieldName) + .map(this::familyNameOf) + .distinct() + .map(Bytes::toBytes) + .collect(Collectors.toList()); this.hbaseClient = hbaseClient == null ? HbaseClient.createInstance(hbaseParameters) : hbaseClient; @@ -102,15 +119,65 @@ public class HbaseSinkWriter @Override public void write(SeaTunnelRow element) throws IOException { - Put put = convertRowToPut(element); - hbaseClient.mutate(put); + failIfUnusable(); + switch (element.getRowKind()) { + case INSERT: + case UPDATE_AFTER: + mutate(convertRowToPut(element)); + break; + case DELETE: + mutate(convertRowToDelete(element)); + break; + case UPDATE_BEFORE: + // Before images are ignored. Images may reach different + // replicas or checkpoints, so this writer cannot pair a key-changing update. + break; + default: + break; + } + } + + /** Submits a mutation, which can also flush rows already accepted into the client buffer. */ + private void mutate(Mutation mutation) throws IOException { + try { + hbaseClient.mutate(mutation); + } catch (IOException e) { + bufferedWriteFailure = e; + throw e; + } } + /** + * Flushes the client buffer at a checkpoint. Keep the native HBase periodic flush disabled when + * relying on checkpoint delivery because the timer can send mutations and report errors + * independently of this writer. Without this explicit flush the {@code BufferedMutator} keeps + * up to {@code write_buffer_size} bytes in memory, and a task failure after the checkpoint + * would lose rows the engine considers written. + */ @Override public Optional<HbaseCommitInfo> prepareCommit() throws IOException { + failIfUnusable(); + try { + hbaseClient.flush(); + } catch (IOException e) { + bufferedWriteFailure = e; + throw e; + } return Optional.empty(); } + /** Rejects further writes/checkpoints after a flush that may have discarded buffered rows. */ + private void failIfUnusable() throws IOException { + if (bufferedWriteFailure != null) { + throw new IOException( + "The HBase sink writer for table " + + hbaseParameters.getTable() + + " cannot continue after a client write failure because buffered rows" + + " may have been lost. Restore from the last successful checkpoint.", + bufferedWriteFailure); + } + } + @Override public void abortPrepare() {} @@ -121,30 +188,75 @@ public class HbaseSinkWriter } } + /** + * A DELETE row removes every version up to its timestamp of the column families this writer + * writes to. Families the job does not map, for example ones owned by another pipeline on the + * same table, are left alone. With no mapped family, HBase would interpret a marker-free + * mutation as a whole-row delete, so reject it before submitting it. + */ + private Delete convertRowToDelete(SeaTunnelRow row) { + if (writtenFamilies.isEmpty()) { + throw new HbaseConnectorException( + CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT, + "Cannot apply a DELETE to HBase table " + + hbaseParameters.getTable() + + " with no mapped column families. Include a non-key payload column" + + " to scope the delete."); + } + long timestamp = mutationTimestamp(row); + Delete delete = new Delete(getRowkeyFromRow(row), timestamp); + for (byte[] family : writtenFamilies) { + delete.addFamily(family, timestamp); + } + if (!hbaseParameters.isWalWrite()) { + delete.setDurability(Durability.SKIP_WAL); + } + return delete; + } + + private String familyNameOf(String fieldName) { + return hbaseParameters.getFamilyNames().getOrDefault(fieldName, defaultFamilyName); + } + + private List<Integer> writeColumnIndexes(int arity) { + return IntStream.range(0, arity) + .boxed() + .filter(index -> !rowkeyColumnIndexes.contains(index)) + .filter(index -> index != versionColumnIndex) + .collect(Collectors.toList()); + } + + /** + * Uses the configured BIGINT epoch milliseconds, or the clock when no version column is set. + */ + private long mutationTimestamp(SeaTunnelRow row) { + if (versionColumnIndex == -1) { + return System.currentTimeMillis(); + } + Object version = row.getField(versionColumnIndex); + if (!(version instanceof Long)) { + throw new HbaseConnectorException( + CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT, + String.format( + "version_column [%s] must hold a non-null BIGINT epoch millisecond" + + " value, got [%s]", + seaTunnelRowType.getFieldName(versionColumnIndex), version)); + } + return (Long) version; + } + private Put convertRowToPut(SeaTunnelRow row) { byte[] rowkey = getRowkeyFromRow(row); - long timestamp = System.currentTimeMillis(); - if (versionColumnIndex != -1) { - timestamp = (Long) row.getField(versionColumnIndex); - } - Put put = new Put(rowkey, timestamp); + Put put = new Put(rowkey, mutationTimestamp(row)); if (hbaseParameters.getTtl() != -1 && hbaseParameters.getTtl() > 0) { put.setTTL(hbaseParameters.getTtl()); } if (!hbaseParameters.isWalWrite()) { put.setDurability(Durability.SKIP_WAL); } - List<Integer> writeColumnIndexes = - IntStream.range(0, row.getArity()) - .boxed() - .filter(index -> !rowkeyColumnIndexes.contains(index)) - .filter(index -> index != versionColumnIndex) - .collect(Collectors.toList()); - for (Integer writeColumnIndex : writeColumnIndexes) { + for (Integer writeColumnIndex : writeColumnIndexes(row.getArity())) { String fieldName = seaTunnelRowType.getFieldName(writeColumnIndex); - Map<String, String> configurationFamilyNames = hbaseParameters.getFamilyNames(); - String familyName = - hbaseParameters.getFamilyNames().getOrDefault(fieldName, defaultFamilyName); + String familyName = familyNameOf(fieldName); byte[] bytes = convertColumnToBytes(row, writeColumnIndex); if (bytes != null) { put.addColumn(Bytes.toBytes(familyName), Bytes.toBytes(fieldName), bytes); diff --git a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClientTest.java b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClientTest.java index f32923e23f..db57301174 100644 --- a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClientTest.java +++ b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClientTest.java @@ -26,6 +26,8 @@ import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.BufferedMutator; import org.apache.hadoop.hbase.client.BufferedMutatorParams; import org.apache.hadoop.hbase.client.Connection; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Scan; @@ -77,11 +79,43 @@ public class HbaseClientTest { assertTrue(client.isExistsData("ns", "tbl")); } + @Test + void testMutateBuffersPutAndDelete() throws Exception { + Connection connection = Mockito.mock(Connection.class); + BufferedMutator mutator = Mockito.mock(BufferedMutator.class); + HbaseClient client = newHbaseClient(connection, mutator); + Put put = new Put(Bytes.toBytes("1")); + Delete delete = new Delete(Bytes.toBytes("2")); + + client.mutate(put); + client.mutate(delete); + + Mockito.verify(mutator).mutate(put); + Mockito.verify(mutator).mutate(delete); + Mockito.verify(mutator, Mockito.never()).flush(); + } + + @Test + void testFlushDelegatesToBufferedMutator() throws Exception { + Connection connection = Mockito.mock(Connection.class); + BufferedMutator mutator = Mockito.mock(BufferedMutator.class); + HbaseClient client = newHbaseClient(connection, mutator); + + client.flush(); + + Mockito.verify(mutator).flush(); + } + private HbaseClient newHbaseClient(Connection connection) throws Exception { + return newHbaseClient(connection, Mockito.mock(BufferedMutator.class)); + } + + private HbaseClient newHbaseClient(Connection connection, BufferedMutator mutator) + throws Exception { HbaseClient.hbaseConfiguration = HBaseConfiguration.create(); Mockito.when(connection.getAdmin()).thenReturn(Mockito.mock(Admin.class)); Mockito.when(connection.getBufferedMutator(any(BufferedMutatorParams.class))) - .thenReturn(Mockito.mock(BufferedMutator.class)); + .thenReturn(mutator); HbaseParameters hbaseParameters = Mockito.mock(HbaseParameters.class); Mockito.when(hbaseParameters.getNamespace()).thenReturn("ns"); Mockito.when(hbaseParameters.getTable()).thenReturn("tbl"); diff --git a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTest.java b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTest.java index 53fd0b9df0..fcfad96db5 100644 --- a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTest.java +++ b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTest.java @@ -18,27 +18,56 @@ package org.apache.seatunnel.connectors.seatunnel.hbase.sink; +import org.apache.seatunnel.api.table.type.BasicType; import org.apache.seatunnel.api.table.type.PrimitiveByteArrayType; +import org.apache.seatunnel.api.table.type.RowKind; import org.apache.seatunnel.api.table.type.SeaTunnelDataType; import org.apache.seatunnel.api.table.type.SeaTunnelRow; import org.apache.seatunnel.api.table.type.SeaTunnelRowType; import org.apache.seatunnel.connectors.seatunnel.hbase.client.HbaseClient; import org.apache.seatunnel.connectors.seatunnel.hbase.config.HbaseParameters; +import org.apache.seatunnel.connectors.seatunnel.hbase.exception.HbaseConnectorException; +import org.apache.hadoop.hbase.CellUtil; +import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Durability; +import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; +import org.apache.hadoop.hbase.util.Bytes; import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.EnumSource; import org.mockito.ArgumentCaptor; import org.mockito.MockedStatic; import org.mockito.Mockito; +import java.io.IOException; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; class HbaseSinkWriterTest { + private static final SeaTunnelRowType ROW_TYPE = + new SeaTunnelRowType( + new String[] {"id", "name", "version"}, + new SeaTunnelDataType[] { + BasicType.INT_TYPE, BasicType.STRING_TYPE, BasicType.LONG_TYPE + }); + @Test void testBinaryRowkeyUsesRawBytes() throws Exception { HbaseParameters hbaseParameters = @@ -63,8 +92,250 @@ class HbaseSinkWriterTest { writer.write(row); } - ArgumentCaptor<Put> putCaptor = ArgumentCaptor.forClass(Put.class); - Mockito.verify(hbaseClient).mutate(putCaptor.capture()); - assertArrayEquals(rowkey, putCaptor.getValue().getRow()); + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertInstanceOf(Put.class, captor.getValue()); + assertArrayEquals(rowkey, captor.getValue().getRow()); + } + + @Test + void testInsertAndUpdateAfterRowsAreWrittenAsPut() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.INSERT, 1, "a", 10L)); + writer.write(row(RowKind.UPDATE_AFTER, 1, "b", 11L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient, Mockito.times(2)).mutate(captor.capture()); + for (Mutation mutation : captor.getAllValues()) { + assertInstanceOf(Put.class, mutation); + assertArrayEquals(Bytes.toBytes("1"), mutation.getRow()); + } + } + + @Test + void testDeleteRowIsWrittenAsDelete() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.DELETE, 7, "gone", 10L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertInstanceOf(Delete.class, captor.getValue()); + assertArrayEquals(Bytes.toBytes("7"), captor.getValue().getRow()); + // Only the family this writer writes to is deleted, as a whole. + assertEquals(Collections.singleton("info"), familiesOf(captor.getValue())); + assertTrue( + captor.getValue().getFamilyCellMap().values().stream() + .flatMap(List::stream) + .allMatch(cell -> CellUtil.cloneQualifier(cell).length == 0)); + } + + @Test + void testDeleteCoversEveryMappedColumnFamily() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + Map<String, String> familyNames = new HashMap<>(); + familyNames.put("name", "cf1"); + familyNames.put("version", "cf2"); + HbaseSinkWriter writer = + new HbaseSinkWriter( + ROW_TYPE, + HbaseParameters.builder().familyNames(familyNames).build(), + Collections.singletonList(0), + -1, + hbaseClient); + + writer.write(row(RowKind.DELETE, 7, "gone", 10L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertEquals(new HashSet<>(Arrays.asList("cf1", "cf2")), familiesOf(captor.getValue())); + } + + private static Set<String> familiesOf(Mutation mutation) { + return mutation.getFamilyCellMap().keySet().stream() + .map(Bytes::toString) + .collect(Collectors.toSet()); + } + + @Test + void testDeleteWithoutMappedColumnsIsRejectedBeforeMutation() { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseParameters parameters = + HbaseParameters.builder() + .table("shared_table") + .familyNames(Collections.singletonMap("all_columns", "info")) + .build(); + SeaTunnelRowType keyOnlyType = + new SeaTunnelRowType( + new String[] {"id", "version"}, + new SeaTunnelDataType[] {BasicType.INT_TYPE, BasicType.LONG_TYPE}); + HbaseSinkWriter writer = + new HbaseSinkWriter( + keyOnlyType, parameters, Collections.singletonList(0), 1, hbaseClient); + SeaTunnelRow delete = new SeaTunnelRow(new Object[] {7, 10L}); + delete.setRowKind(RowKind.DELETE); + + HbaseConnectorException failure = + assertThrows(HbaseConnectorException.class, () -> writer.write(delete)); + assertTrue(failure.getMessage().contains("shared_table")); + assertTrue(failure.getMessage().contains("no mapped column families")); + Mockito.verifyNoInteractions(hbaseClient); + } + + @Test + void testUpdateKeepingRowKeyOnlyWritesTheAfterImage() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.UPDATE_BEFORE, 7, "old", 10L)); + Mockito.verify(hbaseClient, Mockito.never()).mutate(Mockito.any(Mutation.class)); + writer.write(row(RowKind.UPDATE_AFTER, 7, "new", 11L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertInstanceOf(Put.class, captor.getValue()); + assertArrayEquals(Bytes.toBytes("7"), captor.getValue().getRow()); + } + + @Test + void testUpdateMovingRowKeyDoesNotInferAnOldKeyDelete() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.UPDATE_BEFORE, 7, "same", 10L)); + writer.write(row(RowKind.UPDATE_AFTER, 8, "same", 10L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertInstanceOf(Put.class, captor.getValue()); + assertArrayEquals(Bytes.toBytes("8"), captor.getValue().getRow()); + } + + @Test + void testUpdateBeforeIsIgnoredAcrossOtherRows() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.UPDATE_BEFORE, 7, "orphan", 10L)); + writer.write(row(RowKind.INSERT, 1, "a", 10L)); + writer.write(row(RowKind.UPDATE_AFTER, 9, "later", 10L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient, Mockito.times(2)).mutate(captor.capture()); + assertTrue(captor.getAllValues().stream().allMatch(m -> m instanceof Put)); + } + + @Test + void testVersionColumnIsTheTimestampOfPutAndDelete() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), 2); + + writer.write(row(RowKind.INSERT, 7, "here", 1233L)); + writer.write(row(RowKind.DELETE, 7, "gone", 1234L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient, Mockito.times(2)).mutate(captor.capture()); + assertInstanceOf(Put.class, captor.getAllValues().get(0)); + assertEquals(1233L, captor.getAllValues().get(0).getTimestamp()); + assertInstanceOf(Delete.class, captor.getAllValues().get(1)); + assertEquals(1234L, captor.getAllValues().get(1).getTimestamp()); + } + + @Test + void testNullVersionColumnIsRejectedWithTheColumnName() { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), 2); + SeaTunnelRow row = new SeaTunnelRow(new Object[] {7, "gone", null}); + row.setRowKind(RowKind.DELETE); + + HbaseConnectorException exception = + assertThrows(HbaseConnectorException.class, () -> writer.write(row)); + + assertTrue(exception.getMessage().contains("version_column [version]")); + } + + @Test + void testWriterIsUnusableAfterAFailedFlush() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + Mockito.doThrow(new IOException("retries exhausted")).doNothing().when(hbaseClient).flush(); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + writer.write(row(RowKind.INSERT, 1, "a", 10L)); + + assertThrows(IOException.class, writer::prepareCommit); + // The client dropped the failed rows, so a retry must not succeed with them missing. + IOException retry = assertThrows(IOException.class, writer::prepareCommit); + assertEquals("retries exhausted", retry.getCause().getMessage()); + assertThrows(IOException.class, () -> writer.write(row(RowKind.INSERT, 2, "b", 10L))); + Mockito.verify(hbaseClient, Mockito.times(1)).flush(); + } + + @ParameterizedTest + @EnumSource( + value = RowKind.class, + names = {"INSERT", "UPDATE_AFTER", "DELETE"}) + void testWriterIsUnusableAfterMutationDrainsBufferAndFails(RowKind failingKind) + throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + IOException drainFailure = new IOException("implicit drain retries exhausted"); + Mockito.doNothing() + .doThrow(drainFailure) + .doNothing() + .when(hbaseClient) + .mutate(Mockito.any(Mutation.class)); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), 2); + writer.write(row(RowKind.INSERT, 1, "buffered", 10L)); + SeaTunnelRow next = row(failingKind, 2, "next", 11L); + + assertSame(drainFailure, assertThrows(IOException.class, () -> writer.write(next))); + assertSame( + drainFailure, assertThrows(IOException.class, () -> writer.write(next)).getCause()); + assertSame(drainFailure, assertThrows(IOException.class, writer::prepareCommit).getCause()); + Mockito.verify(hbaseClient, Mockito.times(2)).mutate(Mockito.any(Mutation.class)); + Mockito.verify(hbaseClient, Mockito.never()).flush(); + } + + @Test + void testDeleteFollowsWalWriteSetting() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = + newWriter(hbaseClient, HbaseParameters.builder().walWrite(false), -1); + + writer.write(row(RowKind.DELETE, 7, "gone", 10L)); + + ArgumentCaptor<Mutation> captor = ArgumentCaptor.forClass(Mutation.class); + Mockito.verify(hbaseClient).mutate(captor.capture()); + assertEquals(Durability.SKIP_WAL, captor.getValue().getDurability()); + } + + @Test + void testPrepareCommitFlushesBufferedMutations() throws Exception { + HbaseClient hbaseClient = Mockito.mock(HbaseClient.class); + HbaseSinkWriter writer = newWriter(hbaseClient, HbaseParameters.builder(), -1); + + writer.write(row(RowKind.INSERT, 1, "a", 10L)); + writer.prepareCommit(); + + Mockito.verify(hbaseClient).flush(); + } + + private static HbaseSinkWriter newWriter( + HbaseClient hbaseClient, + HbaseParameters.HbaseParametersBuilder parameters, + int versionColumnIndex) { + return new HbaseSinkWriter( + ROW_TYPE, + parameters.familyNames(Collections.singletonMap("all_columns", "info")).build(), + Collections.singletonList(0), + versionColumnIndex, + hbaseClient); + } + + private static SeaTunnelRow row(RowKind kind, int id, String name, long version) { + SeaTunnelRow row = new SeaTunnelRow(new Object[] {id, name, version}); + row.setRowKind(kind); + return row; } } diff --git a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTypeConvertTest.java b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTypeConvertTest.java index 976c1ae0a3..ff507d1188 100644 --- a/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTypeConvertTest.java +++ b/seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/sink/HbaseSinkWriterTypeConvertTest.java @@ -29,6 +29,7 @@ import org.apache.seatunnel.connectors.seatunnel.hbase.format.HBaseDeserializati import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.CellUtil; +import org.apache.hadoop.hbase.client.Mutation; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.util.Bytes; @@ -87,7 +88,7 @@ public class HbaseSinkWriterTypeConvertTest { writer.write(row); ArgumentCaptor<Put> putCaptor = ArgumentCaptor.forClass(Put.class); - verify(hbaseClient).mutate(putCaptor.capture()); + verify(hbaseClient).mutate((Mutation) putCaptor.capture()); Put put = putCaptor.getValue(); assertArrayEquals(Bytes.toBytes("row1"), put.getRow()); diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/hbase/HbaseIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/hbase/HbaseIT.java index a8bf71f369..41597e4955 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/hbase/HbaseIT.java +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/java/org/apache/seatunnel/e2e/connector/hbase/HbaseIT.java @@ -40,6 +40,7 @@ import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.client.Admin; import org.apache.hadoop.hbase.client.Connection; import org.apache.hadoop.hbase.client.Delete; +import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Put; import org.apache.hadoop.hbase.client.Result; import org.apache.hadoop.hbase.client.ResultScanner; @@ -59,8 +60,10 @@ import lombok.extern.slf4j.Slf4j; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -261,6 +264,63 @@ public class HbaseIT extends TestSuiteBase implements TestResource { Assertions.assertEquals(1, execResult.getExitCode()); } + @TestTemplate + public void testHbaseSinkWithCdcRows(TestContainer container) + throws IOException, InterruptedException { + String tableName = "seatunnel_cdc_" + UUID.randomUUID().toString().replace("-", ""); + TableName cdcTable = TableName.valueOf(tableName); + hbaseCluster.createTable(tableName, Arrays.asList(FAMILY_NAME, "other")); + List<String> variables = Collections.singletonList("cdc_table=" + tableName); + byte[] foreignFamily = Bytes.toBytes("other"); + byte[] qualifier = Bytes.toBytes("name"); + byte[] deletedKey = Bytes.toBytes("3"); + byte[] foreignValue = Bytes.toBytes("other pipeline"); + try (Table sharedTable = hbaseConnection.getTable(cdcTable)) { + sharedTable.put( + new Put(deletedKey).addColumn(foreignFamily, qualifier, 1000L, foreignValue)); + Container.ExecResult execResult = + container.executeJob("/fake-to-hbase-with-cdc-rows.conf", variables); + Assertions.assertEquals(0, execResult.getExitCode()); + + Map<String, Map<String, byte[]>> rows = new HashMap<>(); + try (ResultScanner results = + sharedTable.getScanner(new Scan().addFamily(Bytes.toBytes(FAMILY_NAME)))) { + for (Result result : results) { + Map<String, byte[]> cells = new HashMap<>(); + for (Cell cell : result.listCells()) { + cells.put( + Bytes.toString(CellUtil.cloneQualifier(cell)), + CellUtil.cloneValue(cell)); + } + rows.put(Bytes.toString(result.getRow()), cells); + } + } + // id 2 is updated, BEFORE is ignored, id 4 is written, and id 3's mapped family is + // gone. + Assertions.assertEquals(new HashSet<>(Arrays.asList("1", "2", "4")), rows.keySet()); + Assertions.assertEquals("A", Bytes.toString(rows.get("1").get("name"))); + Assertions.assertEquals(10, Bytes.toInt(rows.get("1").get("age"))); + Assertions.assertEquals("B2", Bytes.toString(rows.get("2").get("name"))); + Assertions.assertEquals(21, Bytes.toInt(rows.get("2").get("age"))); + Assertions.assertEquals("A", Bytes.toString(rows.get("4").get("name"))); + Assertions.assertEquals(10, Bytes.toInt(rows.get("4").get("age"))); + Get foreignCell = new Get(deletedKey).addColumn(foreignFamily, qualifier); + Assertions.assertArrayEquals( + foreignValue, sharedTable.get(foreignCell).getValue(foreignFamily, qualifier)); + + Container.ExecResult keyOnly = + container.executeJob("/fake-to-hbase-with-key-only-delete.conf", variables); + Assertions.assertNotEquals(0, keyOnly.getExitCode()); + Assertions.assertTrue( + (keyOnly.getStdout() + keyOnly.getStderr()) + .contains("with no mapped column families")); + Assertions.assertArrayEquals( + foreignValue, sharedTable.get(foreignCell).getValue(foreignFamily, qualifier)); + } finally { + dropTable(cdcTable); + } + } + @TestTemplate public void testHbaseSinkWithArray(TestContainer container) throws IOException, InterruptedException { diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-cdc-rows.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-cdc-rows.conf new file mode 100644 index 0000000000..0bf4a3d060 --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-cdc-rows.conf @@ -0,0 +1,56 @@ +# +# 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. +# + +env { + parallelism = 1 + job.mode = "BATCH" +} + +source { + FakeSource { + schema = { + fields { + id = int + name = string + age = int + version = bigint + } + } + rows = [ + { kind = INSERT, fields = [1, "A", 10, 1000] }, + { kind = INSERT, fields = [2, "B", 20, 1000] }, + { kind = INSERT, fields = [3, "C", 30, 1000] }, + { kind = UPDATE_BEFORE, fields = [2, "B", 20, 1000] }, + { kind = UPDATE_AFTER, fields = [2, "B2", 21, 1001] }, + { kind = UPDATE_BEFORE, fields = [1, "A", 10, 1000] }, + { kind = UPDATE_AFTER, fields = [4, "A", 10, 1001] }, + { kind = DELETE, fields = [3, "C", 30, 1002] } + ] + } +} + +sink { + Hbase { + zookeeper_quorum = "hbase_e2e:2181" + table = ${cdc_table} + rowkey_column = ["id"] + version_column = "version" + family_name { + all_columns = info + } + } +} diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-key-only-delete.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-key-only-delete.conf new file mode 100644 index 0000000000..33f8c8751a --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-hbase-e2e/src/test/resources/fake-to-hbase-with-key-only-delete.conf @@ -0,0 +1,47 @@ +# +# 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. +# + +env { + parallelism = 1 + job.mode = "BATCH" +} + +source { + FakeSource { + schema = { + fields { + id = int + version = bigint + } + } + rows = [ + { kind = DELETE, fields = [3, 1003] } + ] + } +} + +sink { + Hbase { + zookeeper_quorum = "hbase_e2e:2181" + table = ${cdc_table} + rowkey_column = ["id"] + version_column = "version" + family_name { + all_columns = info + } + } +}
