nancyxu825 commented on code in PR #35042: URL: https://github.com/apache/beam/pull/35042#discussion_r2114765150
########## sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/changestreams/dao/PartitionMetadataDao.java: ########## @@ -178,47 +179,57 @@ public List<String> findAllTableIndexes() { * * @return the earliest partition watermark which is not in a {@link State#FINISHED} state. */ - public @Nullable Timestamp getUnfinishedMinWatermark() { + public @Nullable Timestamp getUnfinishedMinWatermark(Optional<Timestamp> since) { + Timestamp sinceTimestamp = since.orElse(Timestamp.MIN_VALUE); Statement statement; + final String minWatermark = "min_watermark"; if (this.isPostgres()) { statement = Statement.newBuilder( - "SELECT \"" + "SELECT min(\"" + COLUMN_WATERMARK - + "\" FROM \"" + + "\") as " + + minWatermark + + " FROM \"" + metadataTableName + "\" WHERE \"" + COLUMN_STATE + "\" != $1" - + " ORDER BY \"" + + " AND \"" + COLUMN_WATERMARK - + "\" ASC LIMIT 1") + + "\" >= $2") .bind("p1") .to(State.FINISHED.name()) + .bind("p2") + .to(sinceTimestamp) .build(); } else { statement = Statement.newBuilder( - "SELECT " + "SELECT min(" Review Comment: Why did you add the changes to add "min" to the query? Technically, you can still do: SELECT COLUMN_WATERMARK from metadatatable where state != FINISHED and Watermark >= previous watermark ORDER BY COLUMN_WATERMARK ASC LIMIT 1? -- 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: github-unsubscr...@beam.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org