You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "yzeng1618 (via GitHub)" <gi...@apache.org> on 2026/01/10 10:29:07 UTC
[PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
yzeng1618 opened a new pull request, #10318:
URL: https://github.com/apache/seatunnel/pull/10318
https://github.com/apache/seatunnel/issues/10301
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
### Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
This PR adds optional `min_timestamp` / `max_timestamp` options to HBaseSource and applies them to HBase Scan#setTimeRange so users can scan data within a timestamp window. It also updates docs and adds unit/E2E tests.
### Does this PR introduce _any_ user-facing change?
Yes. New optional source options `min_timestamp` and `max_timestamp` (epoch milliseconds, [min, max)) allow time-range scans by cell timestamp in HBaseSource. Docs are updated to describe the new options.
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released SeaTunnel versions or within the unreleased branches such as dev.
If no, write 'No'.
If you are adding/modifying connector documents, please follow our new specifications: https://github.com/apache/seatunnel/issues/4544.
-->
### How was this patch tested?
Added unit tests:
- `HbaseClientTest` for time-range scan behavior
- `HbaseParametersTest` for config parsing
- Added E2E test:
- `HbaseIT.testHbaseSourceWithTimeRange` with HBase API timestamped puts + assert on time-range scan
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If you are adding E2E test cases, maybe refer to https://github.com/apache/seatunnel/blob/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-cdc-mysql-e2e/src/test/resources/mysqlcdc_to_mysql.conf, here is a good example.
-->
### Check list
* [ ] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [*] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
* [ ] If necessary, please update `incompatible-changes.md` to describe the incompatibility caused by this PR.
* [ ] If you are contributing the connector code, please check that the following files are updated:
1. Update [plugin-mapping.properties](https://github.com/apache/seatunnel/blob/dev/plugin-mapping.properties) and add new connector information in it
2. Update the pom file of [seatunnel-dist](https://github.com/apache/seatunnel/blob/dev/seatunnel-dist/pom.xml)
3. Add ci label in [label-scope-conf](https://github.com/apache/seatunnel/blob/dev/.github/workflows/labeler/label-scope-conf.yml)
4. Add e2e testcase in [seatunnel-e2e](https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-connector-v2-e2e/)
5. Update connector [plugin_config](https://github.com/apache/seatunnel/blob/dev/config/plugin_config)
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "yzeng1618 (via GitHub)" <gi...@apache.org>.
yzeng1618 commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2685185340
##########
docs/zh/connector-v2/source/Hbase.md:
##########
@@ -33,6 +33,8 @@ import ChangeLog from '../changelog/connector-hbase.md';
| end_rowkey | string | 否 | - |
| start_row_inclusive | boolean | 否 | true |
| end_row_inclusive | boolean | 否 | false |
+| min_timestamp | long | 否 | - |
+| max_timestamp | long | 否 | - |
Review Comment:
Renamed min_timestamp/max_timestamp to start_timestamp/end_timestamp to be consistent with start_rowkey/end_rowkey. The old keys were removed
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2681916078
##########
docs/zh/connector-v2/source/Hbase.md:
##########
@@ -92,6 +94,14 @@ HBase 的行键既可以是文本字符串,也可以是二进制数据。在 S
- **都设置为 false (start_row_inclusive=false, end_row_inclusive=false)**: 这可能会导致**数据丢失**,因为边界行会被所有 split 排除在外。
- **都设置为 true (start_row_inclusive=true, end_row_inclusive=true)**: 这可能会导致**数据重复**,因为边界行会被相邻的多个 split 重复包含。
+### min_timestamp
+
+时间范围扫描的最小时间戳(包含)。单位为毫秒(epoch)。时间范围遵循 [min, max) 左闭右开约定。如果只设置 min_timestamp,则最大值视为无限上界。
+
+### max_timestamp
+
+时间范围扫描的最大时间戳(不包含)。单位为毫秒(epoch)。时间范围遵循 [min, max) 左闭右开约定。如果只设置 max_timestamp,则最小值视为无限下界。
+
Review Comment:
Could you add in the document the effect when start_row/end_row and min_timestamp/max_timestamp are configured at the same time?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2681909746
##########
seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java:
##########
@@ -377,9 +389,22 @@ public ResultScanner scan(
String[] columnNameSplit = columnName.split(":");
scan.addColumn(Bytes.toBytes(columnNameSplit[0]), Bytes.toBytes(columnNameSplit[1]));
}
- return this.connection
- .getTable(TableName.valueOf(hbaseParameters.getTable()))
- .getScanner(scan);
+ return scan;
+ }
+
+ private static void applyTimeRange(Scan scan, HbaseParameters hbaseParameters)
+ throws IOException {
+ Long minTimestamp = hbaseParameters.getMinTimestamp();
+ Long maxTimestamp = hbaseParameters.getMaxTimestamp();
+ if (minTimestamp != null || maxTimestamp != null) {
+ long min = minTimestamp == null ? 0L : minTimestamp;
+ long max = maxTimestamp == null ? Long.MAX_VALUE : maxTimestamp;
+ if (min > max) {
+ throw new IllegalArgumentException(
+ "min_timestamp can't be larger than max_timestamp");
+ }
+ scan.setTimeRange(min, max);
Review Comment:
Let's add some more validations. If the configuration is less than 0, directly report an error. Additionally, there's another issue I need you to confirm: if min == max, is it meaningful in the HBase API?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "yzeng1618 (via GitHub)" <gi...@apache.org>.
yzeng1618 commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2685189058
##########
seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/client/HbaseClient.java:
##########
@@ -377,9 +389,22 @@ public ResultScanner scan(
String[] columnNameSplit = columnName.split(":");
scan.addColumn(Bytes.toBytes(columnNameSplit[0]), Bytes.toBytes(columnNameSplit[1]));
}
- return this.connection
- .getTable(TableName.valueOf(hbaseParameters.getTable()))
- .getScanner(scan);
+ return scan;
+ }
+
+ private static void applyTimeRange(Scan scan, HbaseParameters hbaseParameters)
+ throws IOException {
+ Long minTimestamp = hbaseParameters.getMinTimestamp();
+ Long maxTimestamp = hbaseParameters.getMaxTimestamp();
+ if (minTimestamp != null || maxTimestamp != null) {
+ long min = minTimestamp == null ? 0L : minTimestamp;
+ long max = maxTimestamp == null ? Long.MAX_VALUE : maxTimestamp;
+ if (min > max) {
+ throw new IllegalArgumentException(
+ "min_timestamp can't be larger than max_timestamp");
+ }
+ scan.setTimeRange(min, max);
Review Comment:
Added validations for time range: start_timestamp/end_timestamp must be >= 0, and when both are set we require start_timestamp < end_timestamp. Although HBase Scan#setTimeRange allows min == max at API level, the semantics is [min, max), so min == max results in an empty scan and is usually not meaningful. Therefore we fail fast with an IllegalArgumentException
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang merged PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "zhangshenghang (via GitHub)" <gi...@apache.org>.
zhangshenghang commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2681920939
##########
docs/zh/connector-v2/source/Hbase.md:
##########
@@ -33,6 +33,8 @@ import ChangeLog from '../changelog/connector-hbase.md';
| end_rowkey | string | 否 | - |
| start_row_inclusive | boolean | 否 | true |
| end_row_inclusive | boolean | 否 | false |
+| min_timestamp | long | 否 | - |
+| max_timestamp | long | 否 | - |
Review Comment:
Would it be better if we change the naming to make start_timestamp/end_timestamp and start_rowkey/end_rowkey consistent?
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Feature] [Connector-V2][HBase] Support time-range scan with min/max timestamp in HBaseSource [seatunnel]
Posted by "yzeng1618 (via GitHub)" <gi...@apache.org>.
yzeng1618 commented on code in PR #10318:
URL: https://github.com/apache/seatunnel/pull/10318#discussion_r2685186901
##########
docs/zh/connector-v2/source/Hbase.md:
##########
@@ -92,6 +94,14 @@ HBase 的行键既可以是文本字符串,也可以是二进制数据。在 S
- **都设置为 false (start_row_inclusive=false, end_row_inclusive=false)**: 这可能会导致**数据丢失**,因为边界行会被所有 split 排除在外。
- **都设置为 true (start_row_inclusive=true, end_row_inclusive=true)**: 这可能会导致**数据重复**,因为边界行会被相邻的多个 split 重复包含。
+### min_timestamp
+
+时间范围扫描的最小时间戳(包含)。单位为毫秒(epoch)。时间范围遵循 [min, max) 左闭右开约定。如果只设置 min_timestamp,则最大值视为无限上界。
+
+### max_timestamp
+
+时间范围扫描的最大时间戳(不包含)。单位为毫秒(epoch)。时间范围遵循 [min, max) 左闭右开约定。如果只设置 max_timestamp,则最小值视为无限下界。
+
Review Comment:
Updated the docs to clarify that rowkey range (start_rowkey/end_rowkey) and time range (start_timestamp/end_timestamp) are applied together on the same Scan, so the result is the intersection of both constraints.
--
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.
To unsubscribe, e-mail: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org