You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "JingsongLi (via GitHub)" <gi...@apache.org> on 2023/11/17 06:46:06 UTC

[PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

JingsongLi opened a new pull request, #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336

   <!-- Please specify the module before the PR name: [core] ... or [flink] ... -->
   
   ### Purpose
   
   <!-- Linking this pull request to the issue -->
   Computing engines such as Trino need to convert a row into Trino's own data structure after reading it, which is costly. We can actually perform filtering before returning to Trino to reduce the amount of data that needs to be converted.
   
   Trino Connector can just use `TableRead.executeFilter()` to enable this feature.
   
   <!-- What is the purpose of the change -->
   
   ### Tests
   
   <!-- List UT and IT cases to verify this change -->
   
   ### API and Format
   
   <!-- Does this change affect API or storage format -->
   
   ### Documentation
   
   <!-- Does this change introduce a new feature -->
   


-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1398774483


##########
paimon-core/src/test/java/org/apache/paimon/table/AppendOnlyFileStoreTableTest.java:
##########
@@ -117,6 +118,61 @@ public void testBatchFilter() throws Exception {
                                 "2|21|201|binary|varbinary|mapKey:mapVal|multiset"));
     }
 
+    @Test
+    public void testBatchFilterWithExecution() throws Exception {

Review Comment:
   I think it is the same, so I think it is OK to be just here.



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi merged PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336


-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "tsreaper (via GitHub)" <gi...@apache.org>.
tsreaper commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1398827370


##########
paimon-common/src/main/java/org/apache/paimon/predicate/PredicateProjectionConverter.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.paimon.predicate;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+/** A {@link PredicateVisitor} which converts {@link Predicate} with projection. */
+public class PredicateProjectionConverter implements PredicateReplaceVisitor {
+
+    private final Map<Integer, Integer> reversed;
+
+    public PredicateProjectionConverter(int[] projection) {
+        this.reversed = new HashMap<>();
+        for (int i = 0; i < projection.length; i++) {
+            reversed.put(projection[i], i);
+        }
+    }

Review Comment:
   Is it possible that `projection` contains the same integer? Consider a table with three columns `a`, `b` and `c`, if I query `SELECT a, c, c, b FROM T`, then `projection` might be `[0, 2, 2, 1]`?



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1399032247


##########
paimon-common/src/main/java/org/apache/paimon/predicate/PredicateProjectionConverter.java:
##########
@@ -0,0 +1,47 @@
+/*
+ * 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.paimon.predicate;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+/** A {@link PredicateVisitor} which converts {@link Predicate} with projection. */
+public class PredicateProjectionConverter implements PredicateReplaceVisitor {
+
+    private final Map<Integer, Integer> reversed;
+
+    public PredicateProjectionConverter(int[] projection) {
+        this.reversed = new HashMap<>();
+        for (int i = 0; i < projection.length; i++) {
+            reversed.put(projection[i], i);
+        }
+    }

Review Comment:
   It is OK to just pick a last column reference.



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "JingsongLi (via GitHub)" <gi...@apache.org>.
JingsongLi commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1397120274


##########
paimon-common/src/main/java/org/apache/paimon/predicate/CompoundPredicate.java:
##########
@@ -52,6 +53,11 @@ public boolean test(Object[] values) {
         return function.test(values, children);
     }
 
+    @Override
+    public boolean test(InternalRow row) {
+        return false;

Review Comment:
   you are right



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1398636516


##########
paimon-core/src/test/java/org/apache/paimon/table/AppendOnlyFileStoreTableTest.java:
##########
@@ -117,6 +118,61 @@ public void testBatchFilter() throws Exception {
                                 "2|21|201|binary|varbinary|mapKey:mapVal|multiset"));
     }
 
+    @Test
+    public void testBatchFilterWithExecution() throws Exception {

Review Comment:
   Is it necessary to add a same test in `PrimaryKeyFileStoreTableTest`?



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "Aitozi (via GitHub)" <gi...@apache.org>.
Aitozi commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1396948718


##########
paimon-common/src/main/java/org/apache/paimon/predicate/CompoundPredicate.java:
##########
@@ -52,6 +53,11 @@ public boolean test(Object[] values) {
         return function.test(values, children);
     }
 
+    @Override
+    public boolean test(InternalRow row) {
+        return false;

Review Comment:
   Is this should be `funciton.test(row, children)` ? 



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "Aitozi (via GitHub)" <gi...@apache.org>.
Aitozi commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1396948718


##########
paimon-common/src/main/java/org/apache/paimon/predicate/CompoundPredicate.java:
##########
@@ -52,6 +53,11 @@ public boolean test(Object[] values) {
         return function.test(values, children);
     }
 
+    @Override
+    public boolean test(InternalRow row) {
+        return false;

Review Comment:
   this should be `funciton.test(row, children)` ? 



-- 
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: issues-unsubscribe@paimon.apache.org

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


Re: [PR] [core] Introduce executeFilter to TableRead [incubator-paimon]

Posted by "yuzelin (via GitHub)" <gi...@apache.org>.
yuzelin commented on code in PR #2336:
URL: https://github.com/apache/incubator-paimon/pull/2336#discussion_r1398845486


##########
paimon-core/src/test/java/org/apache/paimon/table/AppendOnlyFileStoreTableTest.java:
##########
@@ -117,6 +118,61 @@ public void testBatchFilter() throws Exception {
                                 "2|21|201|binary|varbinary|mapKey:mapVal|multiset"));
     }
 
+    @Test
+    public void testBatchFilterWithExecution() throws Exception {

Review Comment:
   Alright.



-- 
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: issues-unsubscribe@paimon.apache.org

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