drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] paul-rogers commented on a change in pull request #1888: DRILL-5956: Add Storage Plugin for Apache Druid
Date Sat, 14 Mar 2020 07:09:22 GMT
paul-rogers commented on a change in pull request #1888: DRILL-5956: Add Storage Plugin for
Apache Druid
URL: https://github.com/apache/drill/pull/1888#discussion_r392562535
 
 

 ##########
 File path: contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/DruidFilterBuilder.java
 ##########
 @@ -0,0 +1,195 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.exec.store.druid;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.drill.common.expression.BooleanOperator;
+import org.apache.drill.common.expression.FunctionCall;
+import org.apache.drill.common.expression.LogicalExpression;
+import org.apache.drill.common.expression.visitors.AbstractExprVisitor;
+import org.apache.drill.exec.store.druid.common.DruidUtils;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class DruidFilterBuilder extends
+  AbstractExprVisitor<DruidScanSpec, Void, RuntimeException> {
+
+  private static final Logger logger = LoggerFactory.getLogger(DruidFilterBuilder.class);
+
+  private final DruidGroupScan groupScan;
+  private final LogicalExpression le;
+  private boolean allExpressionsConverted = true;
+  private DruidScanSpecBuilder druidScanSpecBuilder;
+
+  public DruidFilterBuilder(DruidGroupScan groupScan,
+                            LogicalExpression conditionExp) {
+    this.groupScan = groupScan;
+    this.le = conditionExp;
+    this.druidScanSpecBuilder = new DruidScanSpecBuilder();
+  }
+
+  public DruidScanSpec parseTree() throws JsonProcessingException {
+    logger.debug("DruidScanSpec parseTree() called.");
+    DruidScanSpec parsedSpec = le.accept(this, null);
+    if (parsedSpec != null) {
+      parsedSpec = mergeScanSpecs("booleanAnd", this.groupScan.getScanSpec(),
+        parsedSpec);
+    }
+    return parsedSpec;
+  }
+
+  private DruidScanSpec mergeScanSpecs(String functionName,
+                                       DruidScanSpec leftScanSpec,
+                                       DruidScanSpec rightScanSpec) throws JsonProcessingException
{
+    logger.debug("mergeScanSpecs called for functionName - " + functionName);
+
+    String newFilter = null;
+
+    switch (functionName) {
+      case "booleanAnd":
+        if (StringUtils.isNotBlank(leftScanSpec.getFilters())
+          && StringUtils.isNotBlank(rightScanSpec.getFilters())) {
+          newFilter =
+            DruidUtils
+              .andFilterAtIndex(
+                leftScanSpec.getFilters(),
+                rightScanSpec.getFilters()
+              );
+        } else if (leftScanSpec.getFilters() != null) {
+          newFilter = leftScanSpec.getFilters();
+        } else {
+          newFilter = rightScanSpec.getFilters();
+        }
+        break;
+      case "booleanOr":
 
 Review comment:
   Now you can use `FunctionName` constants for these functions also.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message