Alima777 commented on a change in pull request #902: URL: https://github.com/apache/incubator-iotdb/pull/902#discussion_r495537954
########## File path: calcite/src/main/java/org/apache/iotdb/calcite/IoTDBRules.java ########## @@ -0,0 +1,192 @@ +/* + * 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.iotdb.calcite; + +import java.util.List; +import org.apache.calcite.adapter.enumerable.EnumerableLimit; +import org.apache.calcite.adapter.java.JavaTypeFactory; +import org.apache.calcite.plan.Convention; +import org.apache.calcite.plan.RelOptRule; +import org.apache.calcite.plan.RelOptRuleCall; +import org.apache.calcite.plan.RelTraitSet; +import org.apache.calcite.rel.RelNode; +import org.apache.calcite.rel.convert.ConverterRule; +import org.apache.calcite.rel.logical.LogicalFilter; +import org.apache.calcite.rel.logical.LogicalProject; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rex.RexCall; +import org.apache.calcite.rex.RexInputRef; +import org.apache.calcite.rex.RexNode; +import org.apache.calcite.rex.RexVisitorImpl; +import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.validate.SqlValidatorUtil; +import org.apache.iotdb.db.exception.query.LogicalOptimizeException; + +/** + * Rules and relational operators for {@link IoTDBRel#CONVENTION} calling convention. + */ +public class IoTDBRules { + + private IoTDBRules() { + } + + public static final RelOptRule[] RULES = { + IoTDBFilterRule.INSTANCE, + IoTDBProjectRule.INSTANCE, Review comment: Hi, Good point. I impletented the Project rel to push down more operations to IoTDB to avoid querying all data in each query. For example, I want to see the column `s1` in table, if I removed the ProjectRule, the query ` select s1 from "root.vehicle"` will be transformed to ` select * from root.vehicle align by device`. I have to query ALL DATA in storage group `root.vehicle`. The time cost will be unacceptable. But as you mentioned, `a + b` will give the wrong result if it's active, so we can try to modify the rule of Project. Try to push down the single column, and leave `a + b` column for Calcite if possible. And by the way, the aggregation is not push down in this PR as the aggregation method of IoTDB is a bit different from those relations'. We can try to push down partiallly in later PR. ---------------------------------------------------------------- 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]
