You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/09/15 13:20:35 UTC

[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #21006: Optimize push-down for fitler, and support more operators

strongduanmu commented on code in PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006#discussion_r971975517


##########
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-executor-advanced/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/table/TranslatableTableScanExecutor.java:
##########
@@ -207,26 +206,29 @@ private RelNode createRelNode(final ShardingSphereTable table, final Translatabl
         RelOptCluster relOptCluster = RelOptCluster.create(QueryOptimizePlannerFactory.createVolcanoPlanner(), new RexBuilder(new JavaTypeFactoryImpl()));
         RelBuilder builder = RelFactories.LOGICAL_BUILDER.create(relOptCluster, catalogReader).scan(table.getName());
         if (null != scanContext.getFilterValues()) {
-            builder.filter(createFilters(scanContext.getFilterValues(), builder, table.getColumnNames()));
+            builder.filter(createFilters(scanContext.getFilterValues()));
         }
         if (null != scanContext.getProjects()) {
             builder.project(createProjections(scanContext.getProjects(), builder, table.getColumnNames()));
         }
         return builder.build();
     }
     
-    private Collection<RexNode> createFilters(final String[] filterValues, final RelBuilder builder, final List<String> columnNames) {
+    private Collection<RexNode> createFilters(final String[] filterValues) {
         Collection<RexNode> result = new LinkedList<>();
         JavaTypeFactory typeFactory = new JavaTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
         RexBuilder rexBuilder = new RexBuilder(typeFactory);
-        for (int i = 0; i < filterValues.length; i++) {
-            if (!Strings.isNullOrEmpty(filterValues[i])) {
-                RelDataType nonNullableInt = typeFactory.createSqlType(SqlTypeName.INTEGER);
-                RexNode n2 = rexBuilder.makeLiteral(Integer.valueOf(filterValues[i]), nonNullableInt, false);
-                RexNode n1 = rexBuilder.makeInputRef(nonNullableInt, i);
-                RexNode tmp = rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, n1, n2);
-                result.add(tmp);
+        for (String each : filterValues) {
+            if (Strings.isNullOrEmpty(each)) {
+                continue;
+            }
+            RexNode temp = null;

Review Comment:
   Please rename temp to a more meaningful name.



##########
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/antlr4/org/apache/shardingsphere/sqlfederation/optimizer/parser/rexnode/Keyword.g4:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.
+ */
+
+lexer grammar Keyword;

Review Comment:
   Add a new sql parser for sql federation?



##########
shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/pom.xml:
##########
@@ -86,4 +86,25 @@
             <artifactId>calcite-core</artifactId>
         </dependency>
     </dependencies>
+    <build>

Review Comment:
   Why add antlr plugin in shardingsphere-sql-federation-optimizer?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org