dimas-b commented on code in PR #4973:
URL: https://github.com/apache/polaris/pull/4973#discussion_r3548017753
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/QueryGenerator.java:
##########
@@ -66,6 +66,27 @@ public static PreparedQuery generateSelectQuery(
return generateSelectQuery(projections, tableName, whereClause, Map.of(),
null);
}
+ /**
+ * Generates a SELECT query bounded by a row limit. Useful for existence
checks that only need to
+ * know whether any matching row exists, avoiding fetching and materializing
the full result set.
+ *
+ * @param projections List of columns to retrieve.
+ * @param tableName Target table name.
+ * @param whereClause Column-value pairs used in WHERE filtering.
+ * @param limit Maximum number of rows to return.
+ * @return A parameterized SELECT query with a LIMIT clause.
+ * @throws IllegalArgumentException if any whereClause column isn't in
projections.
+ */
+ public static PreparedQuery generateSelectQuery(
+ @NonNull List<String> projections,
+ @NonNull String tableName,
+ @NonNull Map<String, Object> whereClause,
+ int limit) {
+ QueryFragment where = generateWhereClause(new HashSet<>(projections),
whereClause, Map.of());
+ PreparedQuery query = generateSelectQuery(projections, tableName,
where.sql(), null, limit);
+ return new PreparedQuery(query.sql(), where.parameters());
Review Comment:
+1 but I think the validation needs to happen on line 331
--
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]