You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/06/26 07:30:02 UTC
[GitHub] [incubator-paimon] JingsongLi opened a new pull request, #1437: [core] Introduce incremental-between read
JingsongLi opened a new pull request, #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437
<!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
### Purpose
<!-- Linking this pull request to the issue -->
Read incremental changes between start snapshot (exclusive) and end snapshot, for example, '5,10' means changes between snapshot 5 and snapshot 10.
<!-- What is the purpose of the change -->
### Tests
<!-- List UT and IT cases to verify this change -->
### API and Format
<!-- Does this change affect API or storage format -->
### Documentation
<!-- Does this change introduce a new feature -->
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] yuzelin commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1243089620
##########
docs/content/how-to/querying-tables.md:
##########
@@ -119,13 +53,13 @@ SELECT * FROM t /*+ OPTIONS('scan.timestamp-millis' = '1678883047356') */;
you can use `VERSION AS OF` and `TIMESTAMP AS OF` in query to do time travel:
```sql
--- travel to snapshot with id 1L (use snapshot id as version)
+-- read the snapshot with id 1L (use snapshot id as version)
Review Comment:
tab `Saprk3` -> `Spark 3.3+` ?
##########
paimon-core/src/main/java/org/apache/paimon/table/source/snapshot/IncrementalStartingScanner.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.table.source.snapshot;
+
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.Snapshot.CommitKind;
+import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.io.DataFileMeta;
+import org.apache.paimon.operation.ScanKind;
+import org.apache.paimon.table.source.DataSplit;
+import org.apache.paimon.utils.Pair;
+import org.apache.paimon.utils.SnapshotManager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/** {@link StartingScanner} for incremental changes. */
+public class IncrementalStartingScanner implements StartingScanner {
+
+ private final long s1;
+ private final long s2;
Review Comment:
`start`, `end` is better.
##########
paimon-core/src/main/java/org/apache/paimon/schema/SchemaValidation.java:
##########
@@ -199,6 +200,8 @@ private static void validateStartupMode(CoreOptions options) {
options,
Collections.singletonList(SCAN_TIMESTAMP_MILLIS),
Arrays.asList(SCAN_SNAPSHOT_ID, SCAN_TAG_NAME));
+ } else if (options.startupMode() == CoreOptions.StartupMode.INCREMENTAL) {
+ checkOptionExistInMode(options, INCREMENTAL_BETWEEN, options.startupMode());
Review Comment:
Conflict check?
##########
paimon-core/src/main/java/org/apache/paimon/table/source/AbstractInnerTableScan.java:
##########
@@ -130,6 +133,20 @@ protected StartingScanner createStartingScanner(boolean isStreaming) {
return isStreaming
? new ContinuousFromSnapshotFullStartingScanner(options.scanSnapshotId())
: new StaticFromSnapshotStartingScanner(options.scanSnapshotId());
+ case INCREMENTAL:
+ checkArgument(!isStreaming, "Cannot read incremental in streaming mode.");
+ Pair<String, String> incremental = options.incrementalBetween();
+ Preconditions.checkNotNull(
+ incremental,
+ String.format(
+ "%s can not be null when you use %s for %s",
+ CoreOptions.INCREMENTAL_BETWEEN.key(),
+ startupMode,
+ CoreOptions.SCAN_MODE.key()));
Review Comment:
Maybe this is unnecessary because `SchemaValidation` has checked this.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] wxplovecc commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "wxplovecc (via GitHub)" <gi...@apache.org>.
wxplovecc commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1242143668
##########
paimon-core/src/main/java/org/apache/paimon/CoreOptions.java:
##########
@@ -930,6 +941,16 @@ public String scanTagName() {
return options.get(SCAN_TAG_NAME);
}
+ public Pair<String, String> incrementalBetween() {
+ String str = options.get(INCREMENTAL_BETWEEN);
Review Comment:
Check contains `,` ?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] JingsongLi merged pull request #1437: [core] Introduce incremental-between read
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] yuzelin commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1243089373
##########
docs/content/how-to/querying-tables.md:
##########
@@ -119,13 +53,13 @@ SELECT * FROM t /*+ OPTIONS('scan.timestamp-millis' = '1678883047356') */;
you can use `VERSION AS OF` and `TIMESTAMP AS OF` in query to do time travel:
```sql
--- travel to snapshot with id 1L (use snapshot id as version)
+-- read the snapshot with id 1L (use snapshot id as version)
Review Comment:
tab `Spark3` -> `Spark3.3+` ?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] wxplovecc commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "wxplovecc (via GitHub)" <gi...@apache.org>.
wxplovecc commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1242123956
##########
paimon-core/src/main/java/org/apache/paimon/table/source/AbstractInnerTableScan.java:
##########
@@ -127,6 +130,20 @@ protected StartingScanner createStartingScanner(boolean isStreaming) {
}
case FROM_SNAPSHOT_FULL:
return new StaticFromSnapshotStartingScanner(options.scanSnapshotId());
+ case INCREMENTAL:
+ checkArgument(!isStreaming, "Cannot read incremental in streaming mode.");
Review Comment:
isStreaming
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] wxplovecc commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "wxplovecc (via GitHub)" <gi...@apache.org>.
wxplovecc commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1242123956
##########
paimon-core/src/main/java/org/apache/paimon/table/source/AbstractInnerTableScan.java:
##########
@@ -127,6 +130,20 @@ protected StartingScanner createStartingScanner(boolean isStreaming) {
}
case FROM_SNAPSHOT_FULL:
return new StaticFromSnapshotStartingScanner(options.scanSnapshotId());
+ case INCREMENTAL:
+ checkArgument(!isStreaming, "Cannot read incremental in streaming mode.");
Review Comment:
batch mode?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] JingsongLi commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1242276543
##########
paimon-core/src/main/java/org/apache/paimon/table/source/AbstractInnerTableScan.java:
##########
@@ -127,6 +130,20 @@ protected StartingScanner createStartingScanner(boolean isStreaming) {
}
case FROM_SNAPSHOT_FULL:
return new StaticFromSnapshotStartingScanner(options.scanSnapshotId());
+ case INCREMENTAL:
+ checkArgument(!isStreaming, "Cannot read incremental in streaming mode.");
Review Comment:
incremental only support batch mode.
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] reswqa commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "reswqa (via GitHub)" <gi...@apache.org>.
reswqa commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1242578333
##########
paimon-core/src/test/java/org/apache/paimon/table/IncrementalTableTest.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.table;
+
+import org.apache.paimon.CoreOptions;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.utils.Pair;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.apache.paimon.CoreOptions.INCREMENTAL_BETWEEN;
+import static org.apache.paimon.io.DataFileTestUtils.row;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link CoreOptions#INCREMENTAL_BETWEEN}. */
+public class IncrementalTableTest extends TableTestBase {
+
+ @Test
+ public void testPrimaryKeyTable() throws Exception {
+ innerTest(
+ true,
+ "2,5",
+ GenericRow.of(1, 1, 4),
+ GenericRow.of(1, 2, 4),
+ GenericRow.of(2, 1, 4),
+ GenericRow.of(2, 2, 1));
+ }
+
+ @Test
+ public void testAppendTable() throws Exception {
+ innerTest(
+ false,
+ "2,4",
+ GenericRow.of(1, 1, 3),
+ GenericRow.of(1, 2, 3),
+ GenericRow.of(2, 1, 3),
+ GenericRow.of(2, 2, 1),
+ GenericRow.of(1, 1, 4),
+ GenericRow.of(1, 2, 4),
+ GenericRow.of(2, 1, 4));
+ }
+
+ private void innerTest(boolean primary, String incremental, InternalRow... expected)
+ throws Exception {
+ Identifier identifier = identifier("T");
+ Schema.Builder schemaBuilder =
+ Schema.newBuilder()
+ .column("pt", DataTypes.INT())
+ .column("pk", DataTypes.INT())
+ .column("col1", DataTypes.INT())
+ .partitionKeys("pt");
+ if (primary) {
+ schemaBuilder.primaryKey("pk", "pt");
+ }
+ catalog.createTable(identifier, schemaBuilder.build(), true);
+ Table table = catalog.getTable(identifier);
+
+ // snapshot 1: append
+ write(
+ table,
+ GenericRow.of(1, 1, 1),
+ GenericRow.of(1, 2, 1),
+ GenericRow.of(1, 3, 1),
+ GenericRow.of(2, 1, 1));
+
+ // snapshot 2: append
+ write(
+ table,
+ GenericRow.of(1, 1, 2),
+ GenericRow.of(1, 2, 2),
+ GenericRow.of(1, 4, 1),
+ GenericRow.of(2, 1, 2));
+
+ // snapshot 3: compact
+ compact(table, row(1), 0);
+
+ // snapshot 4: append
+ write(
+ table,
+ GenericRow.of(1, 1, 3),
+ GenericRow.of(1, 2, 3),
+ GenericRow.of(2, 1, 3),
+ GenericRow.of(2, 2, 1));
+
+ // snapshot 5: append
+ write(table, GenericRow.of(1, 1, 4), GenericRow.of(1, 2, 4), GenericRow.of(2, 1, 4));
+
+ // snapshot 5
Review Comment:
Maybe this comment is `snapshot6`?
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] JingsongLi commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1243046969
##########
paimon-core/src/test/java/org/apache/paimon/table/IncrementalTableTest.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.table;
+
+import org.apache.paimon.CoreOptions;
+import org.apache.paimon.catalog.Identifier;
+import org.apache.paimon.data.GenericRow;
+import org.apache.paimon.data.InternalRow;
+import org.apache.paimon.schema.Schema;
+import org.apache.paimon.types.DataTypes;
+import org.apache.paimon.utils.Pair;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+
+import static org.apache.paimon.CoreOptions.INCREMENTAL_BETWEEN;
+import static org.apache.paimon.io.DataFileTestUtils.row;
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Test for {@link CoreOptions#INCREMENTAL_BETWEEN}. */
+public class IncrementalTableTest extends TableTestBase {
+
+ @Test
+ public void testPrimaryKeyTable() throws Exception {
+ innerTest(
+ true,
+ "2,5",
+ GenericRow.of(1, 1, 4),
+ GenericRow.of(1, 2, 4),
+ GenericRow.of(2, 1, 4),
+ GenericRow.of(2, 2, 1));
+ }
+
+ @Test
+ public void testAppendTable() throws Exception {
+ innerTest(
+ false,
+ "2,4",
+ GenericRow.of(1, 1, 3),
+ GenericRow.of(1, 2, 3),
+ GenericRow.of(2, 1, 3),
+ GenericRow.of(2, 2, 1),
+ GenericRow.of(1, 1, 4),
+ GenericRow.of(1, 2, 4),
+ GenericRow.of(2, 1, 4));
+ }
+
+ private void innerTest(boolean primary, String incremental, InternalRow... expected)
+ throws Exception {
+ Identifier identifier = identifier("T");
+ Schema.Builder schemaBuilder =
+ Schema.newBuilder()
+ .column("pt", DataTypes.INT())
+ .column("pk", DataTypes.INT())
+ .column("col1", DataTypes.INT())
+ .partitionKeys("pt");
+ if (primary) {
+ schemaBuilder.primaryKey("pk", "pt");
+ }
+ catalog.createTable(identifier, schemaBuilder.build(), true);
+ Table table = catalog.getTable(identifier);
+
+ // snapshot 1: append
+ write(
+ table,
+ GenericRow.of(1, 1, 1),
+ GenericRow.of(1, 2, 1),
+ GenericRow.of(1, 3, 1),
+ GenericRow.of(2, 1, 1));
+
+ // snapshot 2: append
+ write(
+ table,
+ GenericRow.of(1, 1, 2),
+ GenericRow.of(1, 2, 2),
+ GenericRow.of(1, 4, 1),
+ GenericRow.of(2, 1, 2));
+
+ // snapshot 3: compact
+ compact(table, row(1), 0);
+
+ // snapshot 4: append
+ write(
+ table,
+ GenericRow.of(1, 1, 3),
+ GenericRow.of(1, 2, 3),
+ GenericRow.of(2, 1, 3),
+ GenericRow.of(2, 2, 1));
+
+ // snapshot 5: append
+ write(table, GenericRow.of(1, 1, 4), GenericRow.of(1, 2, 4), GenericRow.of(2, 1, 4));
+
+ // snapshot 5
Review Comment:
yes, you are right
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-paimon] JingsongLi commented on a diff in pull request #1437: [core] Introduce incremental-between read
Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #1437:
URL: https://github.com/apache/incubator-paimon/pull/1437#discussion_r1243111698
##########
docs/content/how-to/querying-tables.md:
##########
@@ -119,13 +53,13 @@ SELECT * FROM t /*+ OPTIONS('scan.timestamp-millis' = '1678883047356') */;
you can use `VERSION AS OF` and `TIMESTAMP AS OF` in query to do time travel:
```sql
--- travel to snapshot with id 1L (use snapshot id as version)
+-- read the snapshot with id 1L (use snapshot id as version)
Review Comment:
I will add doc to 3.3+
--
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: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org