yihua commented on code in PR #13523:
URL: https://github.com/apache/hudi/pull/13523#discussion_r2231033894


##########
hudi-common/src/test/java/org/apache/hudi/metadata/TestHoodieBackedTableMetadataBuildPredicate.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.metadata;
+
+import org.apache.hudi.expression.Expression;
+import org.apache.hudi.expression.Predicate;
+
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Tests for HoodieBackedTableMetadata.buildPredicate method.
+ */
+public class TestHoodieBackedTableMetadataBuildPredicate {
+
+  @Test
+  public void testBuildPredicateForSecondaryIndexPartition() {
+    // Test case 1: Secondary index partition with isFullKey = true
+    // Should always use prefix matching regardless of isFullKey

Review Comment:
   This needs to be revisited.



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/testHoodieBackedTableMetadataIndexLookup.scala:
##########
@@ -151,10 +152,13 @@ abstract class 
HoodieBackedTableMetadataIndexLookupTestBase extends HoodieSparkS
     // Create table with specified version
     spark.sql(createTableStatementProvider.apply())
 
-    // Insert initial test data
-    spark.sql(s"insert into $tableName values('1', 'b1', 10, 1000)")
-    spark.sql(s"insert into $tableName values('2', 'b2', 20, 1000)")
-    spark.sql(s"insert into $tableName" + " values('$', '$', 30, 1000)")
+    // Insert initial test data including records with $ characters
+    spark.sql(s"insert into $tableName values('a1', 'b1', 10, 1000)")
+    spark.sql(s"insert into $tableName values('a2', 'b2', 20, 1000)")

Review Comment:
   In a follow-up, another case should be added where multiple record keys have 
the same secondary key value.  Similarly, add a test case where the secondary 
key value is updated for a record key (is there already a test case on this?).



##########
hudi-spark-datasource/hudi-spark/src/test/scala/org/apache/spark/sql/hudi/feature/index/testHoodieBackedTableMetadataIndexLookup.scala:
##########
@@ -319,8 +326,8 @@ abstract class HoodieBackedTableMetadataIndexLookupTestBase 
extends HoodieSparkS
         s"Position should be >= INVALID_POSITION for table version 
${getTableVersion}")
     }
 
-    // Case 3: Non-existing secondary keys
-    val nonExistKeys = HoodieListData.eager(List("non_exist_1", 
"non_exist_2").asJava)
+    // Case 3: Non-existing secondary keys, some matches the prefix of 
existing records
+    val nonExistKeys = HoodieListData.eager(List("", "b", "non_exist_1", 
"non_exist_2").asJava)

Review Comment:
   nit: add `b$$` (secondary key + "$") to make sure it does not return any 
record



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