chamikaramj commented on code in PR #40982:
URL: https://github.com/apache/beam/pull/40982#discussion_r4474478776
##########
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/BeamSqlTable.java:
##########
@@ -92,4 +92,16 @@ default BeamSqlTable forWrite(Map<String, Object> options) {
throw new UnsupportedOperationException(
String.format("%s does not support WITH options for writes",
getClass().getSimpleName()));
}
+
+ /**
+ * Returns the table to read for one {@code CHANGES(...)} call in FROM, such
as {@code SELECT *
+ * FROM CHANGES(t, 5, 10)}: the changes committed in the {@code changes}
range, read with the
Review Comment:
Is the range boundaries here inclusive ? Let's clarify in the documentation.
##########
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/ChangeRange.java:
##########
@@ -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.
+ */
+package org.apache.beam.sdk.extensions.sql.meta;
+
+import com.google.auto.value.AutoValue;
+import java.io.Serializable;
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.joda.time.Instant;
+
+/**
+ * The changes a {@code CHANGES(...)} call reads from a table.
+ *
+ * <p>A range is bounded either by versions or by timestamps, and its bounds
are inclusive. A range
+ * without a start begins wherever the connector starts by default, and a
range without an end reads
+ * up to the latest change.
+ */
+@AutoValue
+public abstract class ChangeRange implements Serializable {
+ public abstract @Nullable Long startVersion();
+
+ public abstract @Nullable Long endVersion();
+
+ public abstract @Nullable Instant startTimestamp();
+
+ public abstract @Nullable Instant endTimestamp();
+
+ /** All changes, as read by {@code CHANGES(t)}. */
+ public static ChangeRange all() {
+ return new AutoValue_ChangeRange(null, null, null, null);
+ }
+
+ /** The changes between two versions, either of which may be open (null). */
+ public static ChangeRange versions(@Nullable Long start, @Nullable Long end)
{
+ return new AutoValue_ChangeRange(start, end, null, null);
+ }
+
+ /** The changes between two timestamps, either of which may be open (null).
*/
Review Comment:
Can we also support ISO 8601 format for timestamps here ?
##########
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/BeamSqlTable.java:
##########
@@ -92,4 +92,16 @@ default BeamSqlTable forWrite(Map<String, Object> options) {
throw new UnsupportedOperationException(
String.format("%s does not support WITH options for writes",
getClass().getSimpleName()));
}
+
+ /**
+ * Returns the table to read for one {@code CHANGES(...)} call in FROM, such
as {@code SELECT *
+ * FROM CHANGES(t, 5, 10)}: the changes committed in the {@code changes}
range, read with the
+ * {@code WITH} options, if any. Everything in {@link #forRead} applies here
too.
+ *
+ * @throws UnsupportedOperationException if this table does not support
{@code CHANGES(...)}
Review Comment:
What happens of the range values are invalid or out of range for the table ?
--
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]