rdblue commented on a change in pull request #4466:
URL: https://github.com/apache/iceberg/pull/4466#discussion_r840943448



##########
File path: python/tests/expression/test_operations.py
##########
@@ -0,0 +1,70 @@
+# 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.
+import pytest
+
+from iceberg.expression.base import And, FalseExp, Not, Or, TrueExp
+
+
[email protected](
+    "op, rep",
+    [
+        (And(TrueExp(), FalseExp()), "And(True, False)"),

Review comment:
       I think it would be better to test with expressions other than True and 
False. Those are markers that will eventually be removed as expression trees 
are built.
   
   Expression trees are built using factory methods that will simplify 
expressions as they are constructed. For example, here's `Expressions.and`:
   
   ```java
     public static Expression and(Expression left, Expression right) {
       Preconditions.checkNotNull(left, "Left expression cannot be null.");
       Preconditions.checkNotNull(right, "Right expression cannot be null.");
       if (left == alwaysFalse() || right == alwaysFalse()) {
         return alwaysFalse();
       } else if (left == alwaysTrue()) {
         return right;
       } else if (right == alwaysTrue()) {
         return left;
       }
       return new And(left, right);
     }
   ```
   
   That means that we never really expect to have True or False in real 
expressions. I think adding a test expression class is a good idea:
   
   ```java
   class ExpressionA(BooleanExpression):
       ...
       def __invert__(self):
           return ExpressionB()
   
   class ExpressionB(BooleanExpression):
       ...
       def __invert(self):
           return ExpressionA()
   ```
   
   Then you could use those expressions in these tests without needing to use 
True/False.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to