code: private boolean isValidBucket(InternalAggregations internalAgg, KunderaQuery query, Expression conditionalExpression)
      {
          if (conditionalExpression instanceof ComparisonExpression)
          {
              Expression expression = ((ComparisonExpression) conditionalExpression).getLeftExpression();
              Object leftValue = getAggregatedResult(internalAgg, ((AggregateFunction) expression).getIdentifier(),
                      expression);
  
              String rightValue = ((ComparisonExpression) conditionalExpression).getRightExpression().toParsedText();
              return validateBucket(leftValue.toString(), rightValue,
                      ((ComparisonExpression) conditionalExpression).getIdentifier());
          }
          else if (LogicalExpression.class.isAssignableFrom(conditionalExpression.getClass()))
          {
              Expression leftExpression = null, rightExpression = null;
              if (conditionalExpression instanceof AndExpression)
              {
                  AndExpression andExpression = (AndExpression) conditionalExpression;
                  leftExpression = andExpression.getLeftExpression();
                  rightExpression = andExpression.getRightExpression();
              }
              else
              {
                  OrExpression orExpression = (OrExpression) conditionalExpression;
                  leftExpression = orExpression.getLeftExpression();
                  rightExpression = orExpression.getRightExpression();
              }
  
              return validateBucket(isValidBucket(internalAgg, query, leftExpression),
                      isValidBucket(internalAgg, query, rightExpression),
                      ((LogicalExpression) conditionalExpression).getIdentifier());
          }
          else
          {
              logger.error("Expression " + conditionalExpression + " in having clause is not supported in Kundera");
              throw new UnsupportedOperationException(conditionalExpression
                      + " in having clause is not supported in Kundera");
          }
      }
docs: Checks if is valid bucket.
  
  @param internalAgg
  the internal agg
  @param query
  the query
  @param conditionalExpression
  the conditional expression
  @return true, if is valid bucket