JulianJaffePinterest commented on a change in pull request #12179:
URL: https://github.com/apache/druid/pull/12179#discussion_r788406204



##########
File path: server/src/main/java/org/apache/druid/server/QueryResource.java
##########
@@ -194,6 +199,30 @@ public Response doPost(
       query = queryLifecycle.getQuery();
       final String queryId = query.getId();
 
+      //Special handling for Walmart case
+      int numFilters;
+      if (query.getContextValue(MAX_NUMERIC_IN_FILTERS) != null) {
+        numFilters = Math.min(DEFAULT_MAX_NUMFILTERS, 
Integer.parseInt(query.getContextValue(MAX_NUMERIC_IN_FILTERS)));
+      } else {
+        numFilters = DEFAULT_MAX_NUMFILTERS;
+      }
+      if (numFilters < 1) {
+        throw new UnsupportedOperationException("Max-Numeric-In-Filters must 
be greater than 0");
+      }
+      if (query.getFilter() instanceof OrDimFilter) {
+        OrDimFilter orDimFilter = (OrDimFilter) query.getFilter();
+        if (orDimFilter.getFields().size() > numFilters) {
+          String dimension = ((BoundDimFilter) 
(orDimFilter.getFields().get(0))).getDimension();
+          throw new UOE(StringUtils.format("Cast values in column [%s] to 
String", dimension));
+        }
+      } else if (query.getFilter() instanceof AndDimFilter) {
+        AndDimFilter andDimFilter = (AndDimFilter) query.getFilter();
+        if (andDimFilter.getFields().size() > numFilters) {
+          String dimension = ((BoundDimFilter) 
(andDimFilter.getFields().get(0))).getDimension();
+          throw new UOE(StringUtils.format("Cast values in column [%s] to 
String", dimension));

Review comment:
       Same comment as for the OrDimFilter case above

##########
File path: server/src/main/java/org/apache/druid/server/QueryResource.java
##########
@@ -194,6 +199,30 @@ public Response doPost(
       query = queryLifecycle.getQuery();
       final String queryId = query.getId();
 
+      //Special handling for Walmart case
+      int numFilters;
+      if (query.getContextValue(MAX_NUMERIC_IN_FILTERS) != null) {
+        numFilters = Math.min(DEFAULT_MAX_NUMFILTERS, 
Integer.parseInt(query.getContextValue(MAX_NUMERIC_IN_FILTERS)));
+      } else {
+        numFilters = DEFAULT_MAX_NUMFILTERS;
+      }
+      if (numFilters < 1) {
+        throw new UnsupportedOperationException("Max-Numeric-In-Filters must 
be greater than 0");
+      }
+      if (query.getFilter() instanceof OrDimFilter) {
+        OrDimFilter orDimFilter = (OrDimFilter) query.getFilter();
+        if (orDimFilter.getFields().size() > numFilters) {
+          String dimension = ((BoundDimFilter) 
(orDimFilter.getFields().get(0))).getDimension();
+          throw new UOE(StringUtils.format("Cast values in column [%s] to 
String", dimension));

Review comment:
       This exception message should be explicit about why it's being thrown. 
Maybe something like `StringUtils.format("[%s]  filters for column [%s] exceeds 
configured filter limit of [%s]! Cast [%s] values to String.", 
orDimFilter.getFields().size(), dimension, numFilters)`?




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to