Skip to content

Commit fec7577

Browse files
committed
[Improve][Connector-V2][HBase] Align timestamp validation
Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
1 parent a7064a1 commit fec7577

4 files changed

Lines changed: 10 additions & 3 deletions

File tree

docs/en/connectors/source/Hbase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ End timestamp (exclusive) for scan time range. Unit: milliseconds since epoch. T
114114

115115
**Notes:**
116116

117-
- `start_timestamp` / `end_timestamp` must be >= 0. If both are set, `start_timestamp` must be < `end_timestamp` (time range is [start, end), so `start_timestamp == end_timestamp` produces an empty scan).
117+
- `start_timestamp` must be >= 0 and `end_timestamp` must be > 0. If both are set, `start_timestamp` must be < `end_timestamp` (time range is [start, end), so `start_timestamp == end_timestamp` produces an empty scan).
118118
- When `start_rowkey` / `end_rowkey` and `start_timestamp` / `end_timestamp` are configured together, both the rowkey range and the time range constraints are applied (intersection).
119119

120120
### common-options

docs/zh/connectors/source/Hbase.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ HBase 的行键既可以是文本字符串,也可以是二进制数据。在 S
113113

114114
**说明:**
115115

116-
- `start_timestamp` / `end_timestamp` 必须大于等于 0;若两者同时配置,需要满足 `start_timestamp < end_timestamp`(遵循 [start, end) 约定,`start_timestamp == end_timestamp` 将导致空扫描)。
116+
- `start_timestamp` 必须大于等于 0,`end_timestamp` 必须大于 0;若两者同时配置,需要满足 `start_timestamp < end_timestamp`(遵循 [start, end) 约定,`start_timestamp == end_timestamp` 将导致空扫描)。
117117
-`start_rowkey` / `end_rowkey``start_timestamp` / `end_timestamp` 同时配置时,会同时应用行键范围与时间范围限制,最终返回两者的交集。
118118

119119
### 常用选项

seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/source/HbaseSourceFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public OptionRule optionRule() {
6262
HbaseSourceOptions.START_TIMESTAMP,
6363
HbaseSourceOptions.END_TIMESTAMP,
6464
Conditions.greaterOrEqual(HbaseSourceOptions.START_TIMESTAMP, 0L),
65-
Conditions.greaterOrEqual(HbaseSourceOptions.END_TIMESTAMP, 0L),
65+
Conditions.greaterThan(HbaseSourceOptions.END_TIMESTAMP, 0L),
6666
Conditions.lessThanField(
6767
HbaseSourceOptions.START_TIMESTAMP,
6868
HbaseSourceOptions.END_TIMESTAMP))

seatunnel-connectors-v2/connector-hbase/src/test/java/org/apache/seatunnel/connectors/seatunnel/hbase/HbaseFactoryTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
import java.util.HashMap;
3232
import java.util.Map;
3333

34+
/**
35+
* Tests factory option rules, including the half-open {@code [start_timestamp, end_timestamp)}
36+
* range.
37+
*/
3438
public class HbaseFactoryTest {
3539

3640
@Test
@@ -44,17 +48,20 @@ void testValidTimestampRanges() {
4448
Assertions.assertDoesNotThrow(() -> validateTimestampRange(null, null));
4549
Assertions.assertDoesNotThrow(() -> validateTimestampRange(0L, null));
4650
Assertions.assertDoesNotThrow(() -> validateTimestampRange(null, 1000L));
51+
Assertions.assertDoesNotThrow(() -> validateTimestampRange(0L, 1L));
4752
Assertions.assertDoesNotThrow(() -> validateTimestampRange(0L, 1000L));
4853
}
4954

5055
@Test
5156
void testNegativeTimestampFails() {
5257
assertInvalidTimestampRange(-1L, null);
5358
assertInvalidTimestampRange(null, -1L);
59+
assertInvalidTimestampRange(null, 0L);
5460
}
5561

5662
@Test
5763
void testInvalidTimestampRangeFails() {
64+
// Equal bounds describe an empty half-open range and are rejected before source creation.
5865
assertInvalidTimestampRange(1000L, 1000L);
5966
assertInvalidTimestampRange(2000L, 1000L);
6067
}

0 commit comments

Comments
 (0)