eric-maynard commented on code in PR #1802: URL: https://github.com/apache/polaris/pull/1802#discussion_r2127228312
########## 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: I wouldn't say it's "very inefficient" to create a map instead of just the keyset. True, we don't need the values, but I don't really think there's much of a performance hit here. -- 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