singhpk234 commented on code in PR #4810:
URL: https://github.com/apache/polaris/pull/4810#discussion_r3455756094
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java:
##########
@@ -1231,6 +1235,45 @@ public List<PolarisPolicyMappingRecord>
loadPoliciesOnTargetByType(
ModelPolicyMappingRecord.ALL_COLUMNS,
ModelPolicyMappingRecord.TABLE_NAME, params));
}
+ /**
+ * Connection-aware version for use inside runWithinTransaction (for
inheritable policy check).
+ */
+ private List<PolarisPolicyMappingRecord> fetchPolicyMappingRecords(
+ QueryGenerator.PreparedQuery query, @NonNull Connection connection) {
+ try {
+ var results =
+ datasourceOperations.executeSelect(connection, query, new
ModelPolicyMappingRecord());
+ return results == null ? Collections.emptyList() : results;
+ } catch (SQLException e) {
+ throw new RuntimeException(
+ String.format("Failed to retrieve policy mapping records %s",
e.getMessage()), e);
+ }
+ }
+
+ /** Connection-aware overload for use inside transaction. */
+ @NonNull
+ public List<PolarisPolicyMappingRecord> loadPoliciesOnTargetByType(
Review Comment:
does this needs to be public ?
##########
persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/DatasourceOperations.java:
##########
@@ -189,6 +189,42 @@ public <T> void executeSelectOverStream(
});
}
+ /** Connection-aware version for use inside runWithinTransaction. */
+ public <T> void executeSelectOverStream(
+ @NonNull Connection connection,
+ @NonNull PreparedQuery query,
+ @NonNull Converter<T> converterInstance,
+ @NonNull Consumer<Stream<T>> consumer)
+ throws SQLException {
+ withRetries(
+ () -> {
+ logQuery(query);
+ try (PreparedStatement statement =
connection.prepareStatement(query.sql())) {
+ List<Object> params = query.parameters();
+ for (int i = 0; i < params.size(); i++) {
+ statement.setObject(i + 1, params.get(i));
+ }
+ try (ResultSet resultSet = statement.executeQuery()) {
+ ResultSetIterator<T> iterator = new
ResultSetIterator<>(resultSet, converterInstance);
+ consumer.accept(iterator.toStream());
+ return null;
+ }
Review Comment:
can we move this to a private function ?
--
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]