eric-maynard commented on code in PR #1838: URL: https://github.com/apache/polaris/pull/1838#discussion_r2139123008
########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/JdbcBasePersistenceImpl.java: ########## @@ -459,29 +461,37 @@ public <T> Page<T> listEntities( entityType.getCode(), "realm_id", realmId); + Map<String, Object> whereGreater = Map.of(); // Limit can't be pushed down, due to client side filtering // absence of transaction. + String orderByColumnName = null; + if (pageToken.paginationRequested()) { + orderByColumnName = ModelEntity.ID_COLUMN; + if (pageToken.hasDataReference()) { + long boundary = entityIdBoundary(pageToken); + whereGreater = Map.of(ModelEntity.ID_COLUMN, boundary); + } + } + try { PreparedQuery query = QueryGenerator.generateSelectQuery( - ModelEntity.ALL_COLUMNS, ModelEntity.TABLE_NAME, params); - List<PolarisBaseEntity> results = new ArrayList<>(); + ModelEntity.ALL_COLUMNS, + ModelEntity.TABLE_NAME, + whereEquals, + whereGreater, + orderByColumnName); + AtomicReference<Page<T>> results = new AtomicReference<>(); datasourceOperations.executeSelectOverStream( query, new ModelEntity(), stream -> { var data = stream.filter(entityFilter); - if (pageToken instanceof HasPageSize hasPageSize) { - data = data.limit(hasPageSize.getPageSize()); - } - data.forEach(results::add); + results.set( + Page.mapped(pageToken, data, transformer, EntityIdPaging::encodedDataReference)); Review Comment: Why are we pushing the limit into `Page.mapped`? This feels beyond the scope of what a `Page` should be handling. If we _are_ pushing it down, why not also push the filter? -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org