You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by fo...@apache.org on 2023/10/24 13:02:31 UTC

[iceberg-python] 01/05: Require full expression parse match (#88)

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

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

commit 2a3c1bdf978487b0505a19119ac02d842337c2ee
Author: Daniel Weeks <da...@gmail.com>
AuthorDate: Sat Oct 21 13:39:37 2023 -0700

    Require full expression parse match (#88)
    
    * Require full expression parse match
    
    * Codestyle
    
    * Update tests/expressions/test_parser.py
    
    Co-authored-by: Fokko Driesprong <fo...@apache.org>
    
    ---------
    
    Co-authored-by: Fokko Driesprong <fo...@apache.org>
---
 pyiceberg/expressions/parser.py  | 2 +-
 tests/expressions/test_parser.py | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/pyiceberg/expressions/parser.py b/pyiceberg/expressions/parser.py
index a5452f5..4580533 100644
--- a/pyiceberg/expressions/parser.py
+++ b/pyiceberg/expressions/parser.py
@@ -252,4 +252,4 @@ boolean_expression = infix_notation(
 
 def parse(expr: str) -> BooleanExpression:
     """Parse a boolean expression."""
-    return boolean_expression.parse_string(expr)[0]
+    return boolean_expression.parse_string(expr, parse_all=True)[0]
diff --git a/tests/expressions/test_parser.py b/tests/expressions/test_parser.py
index 3b21835..65415f2 100644
--- a/tests/expressions/test_parser.py
+++ b/tests/expressions/test_parser.py
@@ -174,3 +174,10 @@ def test_starts_with() -> None:
 
 def test_not_starts_with() -> None:
     assert NotStartsWith("foo", "data") == parser.parse("foo NOT LIKE 'data'")
+
+
+def test_with_function() -> None:
+    with pytest.raises(ParseException) as exc_info:
+        parser.parse("foo = 1 and lower(bar) = '2'")
+
+    assert "Expected end of text, found 'and'" in str(exc_info)