You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ke...@apache.org on 2024/11/27 20:43:06 UTC

(iceberg-python) 06/12: Allow leading underscore in column name used in row filter (#1358)

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

kevinjqliu pushed a commit to branch pyiceberg-0.8.x
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git

commit f3323abfdc344c92e5ce7c0fcd78d133d881c167
Author: vincenzon <mv...@gmail.com>
AuthorDate: Fri Nov 22 04:47:10 2024 -0500

    Allow leading underscore in column name used in row filter (#1358)
    
    * Update parser.py
    
    Allow leading underscore in column name used in row filter.
    
    * Update test_parser.py
    
    * Update test_parser.py
    
    * Update test_parser.py
---
 pyiceberg/expressions/parser.py  | 2 +-
 tests/expressions/test_parser.py | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/pyiceberg/expressions/parser.py b/pyiceberg/expressions/parser.py
index dcd8dceb..056defef 100644
--- a/pyiceberg/expressions/parser.py
+++ b/pyiceberg/expressions/parser.py
@@ -79,7 +79,7 @@ NULL = CaselessKeyword("null")
 NAN = CaselessKeyword("nan")
 LIKE = CaselessKeyword("like")
 
-unquoted_identifier = Word(alphas, alphanums + "_$")
+unquoted_identifier = Word(alphas + "_", alphanums + "_$")
 quoted_identifier = Suppress('"') + unquoted_identifier + Suppress('"')
 identifier = MatchFirst([unquoted_identifier, quoted_identifier]).set_results_name("identifier")
 column = DelimitedList(identifier, delim=".", combine=False).set_results_name("column")
diff --git a/tests/expressions/test_parser.py b/tests/expressions/test_parser.py
index 6096b10f..085150ed 100644
--- a/tests/expressions/test_parser.py
+++ b/tests/expressions/test_parser.py
@@ -53,6 +53,10 @@ def test_quoted_column() -> None:
     assert EqualTo("foo", True) == parser.parse('"foo" = TRUE')
 
 
+def test_leading_underscore() -> None:
+    assert EqualTo("_foo", True) == parser.parse("_foo = true")
+
+
 def test_equals_true() -> None:
     assert EqualTo("foo", True) == parser.parse("foo = true")
     assert EqualTo("foo", True) == parser.parse("foo == TRUE")