jihaozh commented on a change in pull request #5413:
URL: https://github.com/apache/incubator-pinot/pull/5413#discussion_r428288130



##########
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:
       Good point. I plan to add this and add the "SORT BY" functionality in 
the endpoint in a separate PR. 




----------------------------------------------------------------
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

Reply via email to