suxiaogang223 commented on code in PR #51661:
URL: https://github.com/apache/doris/pull/51661#discussion_r2142718914
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonScanNode.java:
##########
@@ -379,7 +380,29 @@ public List<org.apache.paimon.table.source.Split>
getPaimonSplitFromAPI() {
.collect(Collectors.toList())
.indexOf(slot.getColumn().getName()))
.toArray();
- ReadBuilder readBuilder = source.getPaimonTable().newReadBuilder();
+ Table paimonTable = source.getPaimonTable();
+ if (scanParams != null && scanParams.incrementalRead()) {
+ Map<String, String> paimonScanParams = new HashMap<>();
+ paimonScanParams.put("scan.snapshot-id", null);
+ paimonScanParams.put("scan.mode", null);
+
+ String startSnapshotId =
scanParams.getMapParams().get("startSnapshotId");
+ String endSnapshotId =
scanParams.getMapParams().get("endSnapshotId");
+ String incrementalBetweenScanMode = scanParams.getMapParams()
+ .getOrDefault("incrementalBetweenScanMode", "AUTO");
+
+ String startTimestamp =
scanParams.getMapParams().get("startTimestamp");
+ String endTimestamp =
scanParams.getMapParams().get("endTimestamp");
+
+ if (startSnapshotId != null && endSnapshotId != null) {
+ paimonScanParams.put("incremental-between", startSnapshotId +
"," + endSnapshotId);
+ paimonScanParams.put("incremental-between-scan-mode",
incrementalBetweenScanMode);
+ } else if (startTimestamp != null && endTimestamp != null) {
+ paimonScanParams.put("incremental-between-timestamp",
startTimestamp + "," + endTimestamp);
+ }
Review Comment:
Syntax should be:
select * from paimon_table@incr('startTimestamp'='xxx',
['endTimestamp'='xxx']);
##########
regression-test/suites/external_table_p0/paimon/paimon_incr_read.groovy:
##########
@@ -0,0 +1,52 @@
+// 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.
+
+suite("test_paimon_incr_read",
"p0,external,doris,external_docker,external_docker_doris") {
+ logger.info("start paimon test")
+ String enabled = context.config.otherConfigs.get("enablePaimonTest")
+ if (enabled == null || !enabled.equalsIgnoreCase("true")) {
+ logger.info("disable paimon test.")
+ return
+ }
+ String minio_port = context.config.otherConfigs.get("iceberg_minio_port")
+ String catalog_name = "test_paimon_incr_read_catalog"
+ String externalEnvIp = context.config.otherConfigs.get("externalEnvIp")
+ try {
+ sql """drop catalog if exists ${catalog_name}"""
+
+ sql """
+ CREATE CATALOG ${catalog_name} PROPERTIES (
+ 'type' = 'paimon',
+ 'warehouse' = 's3://warehouse/wh',
+ 's3.endpoint' =
'http://${externalEnvIp}:${minio_port}',
+ 's3.access_key' = 'admin',
+ 's3.secret_key' = 'password',
+ 's3.path.style.access' = 'true'
+ );
+ """
+ sql """switch `${catalog_name}`"""
+ sql """use test_paimon_incr_read_db"""
+ qt_snapshot_incr """select * from
paimon_incr@incr('startSnapshotId'=1, 'endSnapshotId'=2)"""
+ logger.info("snapshot_incr test success")
+ qt_timestamp_incr """select * from
paimon_incr@incr('startTimestamp'=0, 'endTimestamp'='99999999999999')"""
Review Comment:
Also test default endTimestamp like:
select * from paimon_incr@incr('startTimestamp'=0)
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/paimon/source/PaimonScanNode.java:
##########
@@ -379,7 +380,29 @@ public List<org.apache.paimon.table.source.Split>
getPaimonSplitFromAPI() {
.collect(Collectors.toList())
.indexOf(slot.getColumn().getName()))
.toArray();
- ReadBuilder readBuilder = source.getPaimonTable().newReadBuilder();
+ Table paimonTable = source.getPaimonTable();
+ if (scanParams != null && scanParams.incrementalRead()) {
+ Map<String, String> paimonScanParams = new HashMap<>();
+ paimonScanParams.put("scan.snapshot-id", null);
+ paimonScanParams.put("scan.mode", null);
+
+ String startSnapshotId =
scanParams.getMapParams().get("startSnapshotId");
+ String endSnapshotId =
scanParams.getMapParams().get("endSnapshotId");
+ String incrementalBetweenScanMode = scanParams.getMapParams()
+ .getOrDefault("incrementalBetweenScanMode", "AUTO");
+
+ String startTimestamp =
scanParams.getMapParams().get("startTimestamp");
+ String endTimestamp =
scanParams.getMapParams().get("endTimestamp");
+
+ if (startSnapshotId != null && endSnapshotId != null) {
+ paimonScanParams.put("incremental-between", startSnapshotId +
"," + endSnapshotId);
+ paimonScanParams.put("incremental-between-scan-mode",
incrementalBetweenScanMode);
+ } else if (startTimestamp != null && endTimestamp != null) {
+ paimonScanParams.put("incremental-between-timestamp",
startTimestamp + "," + endTimestamp);
+ }
Review Comment:
Supports optional parameters endSnapshotId and endTimestamp like hudi
https://doris.apache.org/docs/lakehouse/datalake-analytics/hudi#incremental-read.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]