jihaozh commented on a change in pull request #5413: URL: https://github.com/apache/incubator-pinot/pull/5413#discussion_r428310843
########## File path: thirdeye/thirdeye-pinot/src/main/java/org/apache/pinot/thirdeye/datalayer/util/SqlQueryBuilder.java ########## @@ -338,6 +338,46 @@ public PreparedStatement createFindByParamsStatement(Connection connection, return prepareStatement; } + public PreparedStatement createfindByParamsStatementWithLimit(Connection connection, + Class<? extends AbstractEntity> entityClass, Predicate predicate, Long limit, Long offset) throws Exception { + String tableName = entityMappingHolder.tableToEntityNameMap.inverse().get(entityClass.getSimpleName()); + BiMap<String, String> entityNameToDBNameMapping = + entityMappingHolder.columnMappingPerTable.get(tableName).inverse(); + StringBuilder sqlBuilder = new StringBuilder("SELECT * FROM " + tableName); + StringBuilder whereClause = new StringBuilder(" WHERE "); + List<Pair<String, Object>> parametersList = new ArrayList<>(); + generateWhereClause(entityNameToDBNameMapping, predicate, parametersList, whereClause); + sqlBuilder.append(whereClause.toString()); + sqlBuilder.append(" ORDER BY id DESC"); Review comment: Yes. the id should be good enough for this. Unless we want to sort the result by other columns like names, etc. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org