singhpk234 commented on code in PR #1802:
URL: https://github.com/apache/polaris/pull/1802#discussion_r2129255623
##########
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 agree with you this being done again and again, where there could be
better ways to achieve it and infact i took your recommendation as well, the
way i see "very inefficient" is that we might have performance implication of
doing it, which IMHO should not be, since they are short lived object with very
small memory print.
I totally respect your feedback and have addressed the same, since the
concerns are addressed, I am marking this thread as resolved.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]