From d86ab6ebac96579608de33fc0cd800ac8be212e0 Mon Sep 17 00:00:00 2001 From: vincenzon Date: Fri, 22 Nov 2024 04:47:10 -0500 Subject: [PATCH] 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 dcd8dceb2..056defefb 100644 --- a/pyiceberg/expressions/parser.py +++ b/pyiceberg/expressions/parser.py @@ -79,7 +79,7 @@ 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 6096b10fd..085150ede 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")