qlong commented on code in PR #15384:
URL: https://github.com/apache/iceberg/pull/15384#discussion_r3132676113


##########
api/src/test/java/org/apache/iceberg/expressions/TestExpressionBinding.java:
##########
@@ -350,6 +350,71 @@ public void testExtractExpressionBinding() {
     assertThat(boundExtract.type()).isEqualTo(Types.LongType.get());
   }
 
+  @Test
+  public void testVariantExtractBindingPreservesBracketInputPath() {
+    Expression bound = Binder.bind(STRUCT, lessThan(extract("var", 
"$['event_id']", "long"), 100));
+    BoundPredicate<?> pred = TestHelpers.assertAndUnwrap(bound);
+    BoundExtract<?> boundExtract = (BoundExtract<?>) pred.term();
+    assertThat(boundExtract.path()).isEqualTo("$['event_id']");
+  }
+
+  @Test
+  public void testVariantExtractBindingMixedDotAndBracketPath() {
+    Expression bound =
+        Binder.bind(STRUCT, lessThan(extract("var", "$.employee['user.name']", 
"long"), 100));
+    BoundExtract<?> boundExtract = (BoundExtract<?>) 
TestHelpers.assertAndUnwrap(bound).term();
+    assertThat(boundExtract.path()).isEqualTo("$['employee']['user.name']");
+  }
+
+  @Test
+  public void testVariantExtractBindingBracketPathWithRfc9535Unescape() {
+    // Inner segment is a'b after unescaping; normalized bracket form uses \' 
for the quote.
+    Expression bound = Binder.bind(STRUCT, lessThan(extract("var", 
"$['a\\'b']", "long"), 100));
+    BoundExtract<?> boundExtract = (BoundExtract<?>) 
TestHelpers.assertAndUnwrap(bound).term();
+    assertThat(boundExtract.path()).isEqualTo("$['a\\'b']");
+  }
+
+  @Test
+  public void testVariantExtractBindingBracketPathWithUnicodeEscape() {
+    Expression bound = Binder.bind(STRUCT, lessThan(extract("var", 
"$['\\u00e9']", "long"), 100));
+    BoundExtract<?> boundExtract = (BoundExtract<?>) 
TestHelpers.assertAndUnwrap(bound).term();
+    assertThat(boundExtract.path()).isEqualTo("$['é']");
+  }
+
+  @Test
+  public void 
testVariantExtractUnbindPreservesNormalizedPathForDotInSegmentName() {
+    Expression boundExpr = lessThan(extract("var", "$['a.b']", "long"), 
100L).bind(STRUCT, true);

Review Comment:
   good pointer. Refactored



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