This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git


The following commit(s) were added to refs/heads/main by this push:
     new 829cbb94d Clarify missing literal errors in row filters (#4416)
829cbb94d is described below

commit 829cbb94da728e15ddd5dca7f62cc66b0130fee4
Author: linzch3 <[email protected]>
AuthorDate: Thu Nov 26 08:46:38 2026 +0000

    Clarify missing literal errors in row filters (#4416)
    
    Give the parser names for scalar and list literals so missing values report 
what is expected.
    
    Co-authored-by: linzch3 <[email protected]>
---
 pyiceberg/expressions/parser.py  |  6 ++++--
 tests/expressions/test_parser.py | 12 ++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/pyiceberg/expressions/parser.py b/pyiceberg/expressions/parser.py
index 6150e3ce4..a851b9bd3 100644
--- a/pyiceberg/expressions/parser.py
+++ b/pyiceberg/expressions/parser.py
@@ -121,9 +121,11 @@ boolean = one_of(["true", "false"], caseless=True)
 string = sgl_quoted_string.set_results_name("raw_quoted_string")
 decimal = common.real().set_results_name("decimal")
 integer = common.signed_integer().set_results_name("integer")
-literal = Group(string | decimal | integer | 
boolean).set_results_name("literal")
+literal = Group((string | decimal | integer | boolean).set_name("a literal 
value")).set_results_name("literal")
 literal_set = Group(
-    DelimitedList(string) | DelimitedList(decimal) | DelimitedList(integer) | 
DelimitedList(boolean)
+    (DelimitedList(string) | DelimitedList(decimal) | DelimitedList(integer) | 
DelimitedList(boolean)).set_name(
+        "a non-empty list of literals"
+    )
 ).set_results_name("literal_set")
 
 
diff --git a/tests/expressions/test_parser.py b/tests/expressions/test_parser.py
index 581ee90b7..74a2e82a0 100644
--- a/tests/expressions/test_parser.py
+++ b/tests/expressions/test_parser.py
@@ -126,6 +126,18 @@ def test_not_equal_to() -> None:
     assert NotEqualTo("foo", 5) == parser.parse("5 <> foo")
 
 
[email protected](
+    ("expression", "message"),
+    [
+        ("id =", "Expected a literal value"),
+        ("id IN ()", "Expected a non-empty list of literals"),
+    ],
+)
+def test_missing_literal_error(expression: str, message: str) -> None:
+    with pytest.raises(ParseException, match=message):
+        parser.parse(expression)
+
+
 def test_in() -> None:
     assert In("foo", {5, 6, 7}) == parser.parse("foo in (5, 6, 7)")
     assert In("foo", {"a", "b", "c"}) == parser.parse("foo IN ('a', 'b', 'c')")

Reply via email to