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 12:18:44 UTC

[GitHub] [shardingsphere] boyjoy1127 opened a new pull request, #21006: Optimize push-down for fitler, and support more operators

boyjoy1127 opened a new pull request, #21006:
URL: https://github.com/apache/shardingsphere/pull/21006

   
   
   Ref #19937.
   
   Changes proposed in this pull request:
     - optimize push-down for filters. 
     - support more operators for operating integer parameters. These operators are: like, search, and, or, not ,equals, <, <=, >, >=, =,!=,<>.
    
   


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


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

Posted by GitBox <gi...@apache.org>.
boyjoy1127 commented on code in PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006#discussion_r972488714


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

Review Comment:
   Because the ANTLR is used to unserialize the filter condition.



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


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

Posted by GitBox <gi...@apache.org>.
boyjoy1127 commented on code in PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006#discussion_r972488390


##########
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:
   OK.



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


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

Posted by GitBox <gi...@apache.org>.
boyjoy1127 commented on code in PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006#discussion_r972488839


##########
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 filter condition parser.



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


[GitHub] [shardingsphere] strongduanmu merged pull request #21006: Optimize push-down for fitler, and support more operators

Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006


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


[GitHub] [shardingsphere] codecov-commenter commented on pull request #21006: Optimize push-down for fitler, and support more operators

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #21006:
URL: https://github.com/apache/shardingsphere/pull/21006#issuecomment-1248202094

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/21006?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#21006](https://codecov.io/gh/apache/shardingsphere/pull/21006?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (f119bff) into [master](https://codecov.io/gh/apache/shardingsphere/commit/84245e84b38146e20e49e474069cf4da27401f9b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (84245e8) will **decrease** coverage by `0.15%`.
   > The diff coverage is `2.23%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #21006      +/-   ##
   ============================================
   - Coverage     61.75%   61.60%   -0.16%     
     Complexity     2467     2467              
   ============================================
     Files          4050     4054       +4     
     Lines         55560    55688     +128     
     Branches       9413     9446      +33     
   ============================================
   - Hits          34309    34304       -5     
   - Misses        18376    18513     +137     
   + Partials       2875     2871       -4     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/21006?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../advanced/table/TranslatableTableScanExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLWV4ZWN1dG9yL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLWV4ZWN1dG9yLWFkdmFuY2VkL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9zcWxmZWRlcmF0aW9uL2FkdmFuY2VkL3RhYmxlL1RyYW5zbGF0YWJsZVRhYmxlU2NhbkV4ZWN1dG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ter/exception/OptimizationSQLRexNodeException.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvY29udmVydGVyL2V4Y2VwdGlvbi9PcHRpbWl6YXRpb25TUUxSZXhOb2RlRXhjZXB0aW9uLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...metadata/translatable/ParseRexNodeVisitorImpl.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvbWV0YWRhdGEvdHJhbnNsYXRhYmxlL1BhcnNlUmV4Tm9kZVZpc2l0b3JJbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...zer/metadata/translatable/StringToRexNodeUtil.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvbWV0YWRhdGEvdHJhbnNsYXRhYmxlL1N0cmluZ1RvUmV4Tm9kZVV0aWwuamF2YQ==) | `0.00% <0.00%> (ø)` | |
   | [...r/metadata/translatable/TranslatableTableScan.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uL3NoYXJkaW5nc3BoZXJlLXNxbC1mZWRlcmF0aW9uLW9wdGltaXplci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsZmVkZXJhdGlvbi9vcHRpbWl6ZXIvbWV0YWRhdGEvdHJhbnNsYXRhYmxlL1RyYW5zbGF0YWJsZVRhYmxlU2Nhbi5qYXZh) | `66.66% <60.00%> (+3.15%)` | :arrow_up: |
   | [...sql/ingest/client/netty/MySQLNegotiateHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUta2VybmVsL3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUvc2hhcmRpbmdzcGhlcmUtZGF0YS1waXBlbGluZS1kaWFsZWN0L3NoYXJkaW5nc3BoZXJlLWRhdGEtcGlwZWxpbmUtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvbXlzcWwvaW5nZXN0L2NsaWVudC9uZXR0eS9NeVNRTE5lZ290aWF0ZUhhbmRsZXIuamF2YQ==) | `43.47% <0.00%> (-5.31%)` | :arrow_down: |
   | [...packet/handshake/MySQLAuthSwitchRequestPacket.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wvc2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RiL3Byb3RvY29sL215c3FsL3BhY2tldC9oYW5kc2hha2UvTXlTUUxBdXRoU3dpdGNoUmVxdWVzdFBhY2tldC5qYXZh) | `30.76% <0.00%> (ø)` | |
   | [...ocol/mysql/constant/MySQLAuthenticationPlugin.java](https://codecov.io/gh/apache/shardingsphere/pull/21006/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wvc2hhcmRpbmdzcGhlcmUtZGItcHJvdG9jb2wtbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RiL3Byb3RvY29sL215c3FsL2NvbnN0YW50L015U1FMQXV0aGVudGljYXRpb25QbHVnaW4uamF2YQ==) | `0.00% <0.00%> (ø)` | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


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

Posted by GitBox <gi...@apache.org>.
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