adutra commented on code in PR #1802: URL: https://github.com/apache/polaris/pull/1802#discussion_r2128696335
########## persistence/relational-jdbc/src/main/java/org/apache/polaris/persistence/relational/jdbc/QueryGenerator.java: ########## @@ -34,38 +37,67 @@ import org.apache.polaris.persistence.relational.jdbc.models.ModelGrantRecord; import org.apache.polaris.persistence.relational.jdbc.models.ModelPolicyMappingRecord; import org.apache.polaris.persistence.relational.jdbc.models.ModelPrincipalAuthenticationData; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class QueryGenerator { + private static final Logger log = LoggerFactory.getLogger(QueryGenerator.class); + private final DatabaseType databaseType; - public static <T> String generateSelectQuery( + public QueryGenerator(DatabaseType databaseType) { + this.databaseType = databaseType; + } + + public DatabaseType getDatabaseType() { + return databaseType; + } + + public static class PreparedQuery { + private final String sql; + private final List<Object> parameters; + + public PreparedQuery(String sql, List<Object> parameters) { + this.sql = sql; + this.parameters = parameters; + } + + public String getSql() { + return sql; + } + + public List<Object> getParameters() { + return parameters; + } + } + + public <T> PreparedQuery generateSelectQuery( @Nonnull Converter<T> entity, @Nonnull Map<String, Object> whereClause) { - return generateSelectQuery(entity, generateWhereClause(whereClause)); + + String tableName = getTableName(entity.getClass()); + Map<String, Object> objectMap = entity.toMap(databaseType); Review Comment: ... and you are doing this again and again for _every_ SQL query, while doing this only once and storing the result in a static field would be enough. I think this qualifies as "very inefficient". -- 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