paul-rogers commented on a change in pull request #1892: Drill-7437: Storage Plugin for Generic HTTP REST API URL: https://github.com/apache/drill/pull/1892#discussion_r352254083
########## File path: contrib/storage-http/src/main/java/org/apache/drill/exec/store/http/HttpFilterBuilder.java ########## @@ -0,0 +1,127 @@ +/* + * 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.http; + +import java.util.List; + +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.SchemaPath; +import org.apache.drill.common.expression.visitors.AbstractExprVisitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class HttpFilterBuilder extends + AbstractExprVisitor<HttpScanSpec, Void, RuntimeException> { + static final Logger logger = LoggerFactory.getLogger(HttpFilterBuilder.class); + private final HttpGroupScan groupScan; + private final LogicalExpression le; + private boolean allExpressionsConverted = true; + + public boolean isAllExpressionsConverted() { + return allExpressionsConverted; + } + + public HttpFilterBuilder(HttpGroupScan groupScan, LogicalExpression conditionExp) { + this.groupScan = groupScan; + this.le = conditionExp; + logger.debug("HttpFilterBuilder created"); + } + + public HttpScanSpec parseTree() { + HttpScanSpec parsedSpec = le.accept(this, null); + if (parsedSpec != null) { + parsedSpec = mergeScanSpecs(this.groupScan.getScanSpec(), parsedSpec); + } + return parsedSpec; + } + + private HttpScanSpec mergeScanSpecs(HttpScanSpec leftScanSpec, HttpScanSpec rightScanSpec) { + leftScanSpec.merge(rightScanSpec); + return leftScanSpec; + } + + @Override + public HttpScanSpec visitUnknown(LogicalExpression e, Void value) + throws RuntimeException { + allExpressionsConverted = false; + return null; + } + + // only process `boolean and` expression + // `a and b and c` will call this, and argument size = 3 + @Override + public HttpScanSpec visitBooleanOperator(BooleanOperator op, Void value) { Review comment: Drill supports both AND and OR. Looks like this code checks for AND, but happily handles OR clauses. FWIW: I'm trying to create a generic form of this stuff since as I discovered the hard way, it is very hard to get this stuff right and nearly impossible to test generically. There will be a PR with a generic form and a "test mule" data source that shows handling of AND and OR. It also includes a generic processor to translate from Drill structure to a very simple RelOp structure. Your choice as to whether to forge ahead with the current approach, or wait for the new stuff. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services