You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/01/07 22:55:00 UTC

[jira] [Work logged] (BEAM-8993) [SQL] MongoDb should use predicate push-down

     [ https://issues.apache.org/jira/browse/BEAM-8993?focusedWorklogId=367844&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-367844 ]

ASF GitHub Bot logged work on BEAM-8993:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 07/Jan/20 22:54
            Start Date: 07/Jan/20 22:54
    Worklog Time Spent: 10m 
      Work Description: TheNeuralBit commented on pull request #10417: [BEAM-8993] [SQL] MongoDB predicate push down.
URL: https://github.com/apache/beam/pull/10417#discussion_r363946226
 
 

 ##########
 File path: sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/mongodb/MongoDbFilter.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.beam.sdk.extensions.sql.meta.provider.mongodb;
+
+import static org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.SqlKind.AND;
+import static org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.SqlKind.COMPARISON;
+import static org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.SqlKind.OR;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.beam.sdk.extensions.sql.meta.BeamSqlTableFilter;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rex.RexCall;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rex.RexInputRef;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rex.RexLiteral;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.rex.RexNode;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.SqlKind;
+import org.apache.beam.vendor.calcite.v1_20_0.org.apache.calcite.sql.type.SqlTypeName;
+
+public class MongoDbFilter implements BeamSqlTableFilter {
+  private List<RexNode> supported;
+  private List<RexNode> unsupported;
+
+  public MongoDbFilter(List<RexNode> predicateCNF) {
+    supported = new ArrayList<>();
+    unsupported = new ArrayList<>();
+
+    for (RexNode node : predicateCNF) {
+      if (!node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {
+        throw new RuntimeException(
+            "Predicate node '"
+                + node.getClass().getSimpleName()
+                + "' should be a boolean expression, but was: "
+                + node.getType().getSqlTypeName());
+      }
+
+      if (isSupported(node)) {
+        supported.add(node);
+      } else {
+        unsupported.add(node);
+      }
 
 Review comment:
   You shouldn't do work in a constructor. I think this constructor should accept a supported and an unsupported `List` and maybe be private. There could be a static initializer that will accept a single list and partition it into supported and unsupported.
 
----------------------------------------------------------------
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:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 367844)
    Time Spent: 20m  (was: 10m)

> [SQL] MongoDb should use predicate push-down
> --------------------------------------------
>
>                 Key: BEAM-8993
>                 URL: https://issues.apache.org/jira/browse/BEAM-8993
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Kirill Kozlov
>            Assignee: Kirill Kozlov
>            Priority: Major
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> * Add a MongoDbFilter class, implementing BeamSqlTableFilter.
>  ** Support simple comparison operations.
>  ** Support boolean field.
>  ** Support nested conjunction/disjunction.
>  * Update MongoDbTable#buildIOReader
>  ** Construct a push-down filter from RexNodes.
>  ** Set filter to FindQuery.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)