yashmayya commented on code in PR #16043: URL: https://github.com/apache/pinot/pull/16043#discussion_r2140198489
########## pinot-common/src/main/java/org/apache/pinot/sql/parsers/rewriter/RlsFiltersRewriter.java: ########## @@ -0,0 +1,39 @@ +package org.apache.pinot.sql.parsers.rewriter; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.calcite.sql.SqlKind; +import org.apache.commons.collections4.MapUtils; +import org.apache.pinot.common.request.DataSource; +import org.apache.pinot.common.request.Expression; +import org.apache.pinot.common.request.PinotQuery; +import org.apache.pinot.common.utils.request.RequestUtils; +import org.apache.pinot.spi.utils.builder.TableNameBuilder; +import org.apache.pinot.sql.parsers.CalciteSqlParser; + + +public class RlsFiltersRewriter implements QueryRewriter { + + private static final String ROW_FILTERS = "rowFilters"; + + @Override + public PinotQuery rewrite(PinotQuery pinotQuery) { + Map<String, String> queryOptions = pinotQuery.getQueryOptions(); + if (!MapUtils.isEmpty(queryOptions)) { + String tableName = pinotQuery.getDataSource().getTableName(); + String rawTableName = TableNameBuilder.extractRawTableName(tableName); + String rowFilters = queryOptions.get(rawTableName); + Expression expression = CalciteSqlParser.compileToExpression(rowFilters); + Expression existingFilterExpression = pinotQuery.getFilterExpression(); + if (existingFilterExpression != null) { + Expression combinedFilterExpression = + RequestUtils.getFunctionExpression(SqlKind.AND.toString(), List.of(expression, existingFilterExpression)); Review Comment: nit: I'd suggest using `FilterKind.AND.name()` here instead even though the string values will be identical (Pinot vs Calcite definition, since this is part of the v1 engine). -- 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: commits-unsubscr...@pinot.apache.org 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