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_r392563157
########## File path: contrib/storage-druid/src/main/java/org/apache/drill/exec/store/druid/DruidScanSpecBuilder.java ########## @@ -0,0 +1,139 @@ +/* + * 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 org.apache.drill.common.expression.SchemaPath; +import org.apache.drill.exec.store.druid.common.DruidBoundFilter; +import org.apache.drill.exec.store.druid.common.DruidIntervalFilter; +import org.apache.drill.exec.store.druid.common.DruidNotFilter; +import org.apache.drill.exec.store.druid.common.DruidRegexFilter; +import org.apache.drill.exec.store.druid.common.DruidSearchFilter; +import org.apache.drill.exec.store.druid.common.DruidSelectorFilter; +import org.apache.drill.exec.store.druid.druid.SelectQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; + +class DruidScanSpecBuilder { + + private static final Logger logger = LoggerFactory.getLogger(DruidScanSpecBuilder.class); + + private static final String REGEX_KEYWORD_HINT = "$regex$_"; + + DruidScanSpec build(String dataSourceName, + String functionName, + SchemaPath field, + Object fieldValue) throws IOException { + // extract the field name + + String fieldName = field.getAsNamePart().getName(); //.getAsUnescapedPath(); + String filter; + + logger.debug("createDruidScanSpec called. FunctionName - " + + functionName + ", field - " + fieldName + ", fieldValue - " + fieldValue); + + switch (functionName) { Review comment: Suggestion: maybe put this switch in a function so you can just say: ``` String filter = translateFilter(function); ``` And: ``` case "equal": return new DruidIntervalFilter((String)fieldValue).toJson() ... ``` Also, how do we know that `filter` is a String? Did we convert it from the Drill type elsewhere? If so, should we pass `filter` in as a `String`? If we don't know, should we pass a (type, value) pair so we know how to convert? The ill-fated PR #1914 has some code to help with this kind of thing. ---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services
