vvysotskyi commented on a change in pull request #2135: URL: https://github.com/apache/drill/pull/2135#discussion_r557576188
########## File path: contrib/storage-elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/CalciteUtils.java ########## @@ -0,0 +1,83 @@ +/* + * 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.calcite.adapter.elasticsearch; + +import org.apache.calcite.plan.RelOptRule; +import org.apache.calcite.plan.RelTraitSet; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.convert.ConverterRule; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rex.RexNode; +import org.apache.drill.exec.store.elasticsearch.ElasticsearchStorageConfig; +import org.apache.drill.exec.store.elasticsearch.plan.ElasticSearchEnumerablePrelContext; +import org.apache.drill.exec.store.elasticsearch.plan.ElasticsearchFilterRule; +import org.apache.drill.exec.store.elasticsearch.plan.ElasticsearchProjectRule; +import org.apache.drill.exec.store.enumerable.plan.EnumerableIntermediatePrelConverterRule; +import org.apache.drill.exec.store.enumerable.plan.VertexDrelConverterRule; + +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +public class CalciteUtils { + + private static final List<String> BANNED_RULES = + Arrays.asList("ElasticsearchProjectRule", "ElasticsearchFilterRule"); + + public static final Predicate<RelOptRule> RULE_PREDICATE = + relOptRule -> BANNED_RULES.stream() + .noneMatch(banned -> relOptRule.toString().startsWith(banned)); + + public static final VertexDrelConverterRule ELASTIC_DREL_CONVERTER_RULE = + new VertexDrelConverterRule(ElasticsearchRel.CONVENTION); + + public static final EnumerableIntermediatePrelConverterRule ENUMERABLE_INTERMEDIATE_PREL_CONVERTER_RULE = + new EnumerableIntermediatePrelConverterRule( + new ElasticSearchEnumerablePrelContext(ElasticsearchStorageConfig.NAME)); + + public static Set<RelOptRule> elasticSearchRules() { + Set<RelOptRule> rules = Arrays.stream(ElasticsearchRules.RULES) + .filter(RULE_PREDICATE) Review comment: Thanks, added. Don't think these Calcite rules will fit our requirements in the future. ---------------------------------------------------------------- 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]
