Skip to content

Commit

Permalink
more subquery
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik authored and Amogh-Bharadwaj committed Nov 29, 2024
1 parent f729690 commit b336ac5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flow/connectors/postgres/qrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (c *PostgresConnector) getNumRowsPartitions(
`SELECT bucket, MIN(%[2]s) AS start, MAX(%[2]s) AS end
FROM (
SELECT NTILE(%[1]d) OVER (ORDER BY %[2]s) AS bucket, %[2]s
FROM (%[3]s) WHERE %[2]s > $1
FROM (%[3]s) inner_subquery WHERE %[2]s > $1
) subquery
GROUP BY bucket
ORDER BY start
Expand All @@ -151,7 +151,7 @@ func (c *PostgresConnector) getNumRowsPartitions(
partitionsQuery := fmt.Sprintf(
`SELECT bucket, MIN(%[2]s) AS start, MAX(%[2]s) AS end
FROM (
SELECT NTILE(%[1]d) OVER (ORDER BY %[2]s) AS bucket, %[2]s FROM (%[3]s)
SELECT NTILE(%[1]d) OVER (ORDER BY %[2]s) AS bucket, %[2]s FROM (%[3]s) inner_subquery
) subquery
GROUP BY bucket
ORDER BY start
Expand Down

0 comments on commit b336ac5

Please sign in to comment.