wombatu-kun commented on code in PR #13481:
URL: https://github.com/apache/hudi/pull/13481#discussion_r3519593871


##########
hudi-common/src/test/java/org/apache/hudi/expression/PredicatesTest.java:
##########
@@ -0,0 +1,239 @@
+/*
+ * 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.hudi.expression;
+
+import org.apache.hudi.expression.Predicates.And;
+import org.apache.hudi.expression.Predicates.BinaryComparison;
+import org.apache.hudi.expression.Predicates.In;
+import org.apache.hudi.expression.Predicates.IsNotNull;
+import org.apache.hudi.expression.Predicates.IsNull;
+import org.apache.hudi.expression.Predicates.Not;
+import org.apache.hudi.expression.Predicates.Or;
+import org.apache.hudi.expression.Predicates.StringContains;
+import org.apache.hudi.expression.Predicates.StringStartsWith;
+import org.apache.hudi.expression.Predicates.StringStartsWithAny;
+import org.apache.hudi.internal.schema.Types;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.apache.hudi.expression.Predicates.alwaysFalse;
+import static org.apache.hudi.expression.Predicates.alwaysTrue;
+import static org.apache.hudi.expression.Predicates.and;
+import static org.apache.hudi.expression.Predicates.contains;
+import static org.apache.hudi.expression.Predicates.eq;
+import static org.apache.hudi.expression.Predicates.gt;
+import static org.apache.hudi.expression.Predicates.gteq;
+import static org.apache.hudi.expression.Predicates.in;
+import static org.apache.hudi.expression.Predicates.isNotNull;
+import static org.apache.hudi.expression.Predicates.isNull;
+import static org.apache.hudi.expression.Predicates.lteq;
+import static org.apache.hudi.expression.Predicates.not;
+import static org.apache.hudi.expression.Predicates.or;
+import static org.apache.hudi.expression.Predicates.startsWith;
+import static org.apache.hudi.expression.Predicates.startsWithAny;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+class PredicatesTest {
+
+  // Define some common literal expressions for use in tests
+  private final Expression a = new Literal<>("a", Types.StringType.get());

Review Comment:
   Every assertEquals here reuses the same operand instances (a, b, c), so 
operand equality is never exercised by value. Literal and NameReference do not 
override equals (Literal.java:35, NameReference.java:28 carry only 
@AllArgsConstructor/@Getter), so the predicate @EqualsAndHashCode compares 
operands by identity: two predicates built from distinct-but-equal operands are 
unequal - exactly the independently-built-tree case the Trino Expression Index 
comparison relies on. This test fails today, and passes once @EqualsAndHashCode 
is added to the leaf types Literal and NameReference:
   
   ```java
   @Test
   void testEqualsWithDistinctButEqualOperands() {
     Expression a1 = new Literal<>("a", Types.StringType.get());
     Expression a2 = new Literal<>("a", Types.StringType.get());
     assertEquals(isNull(a1), isNull(a2));
   }
   ```



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

Reply via email to