diff --git a/pyiceberg/expressions/parser.py b/pyiceberg/expressions/parser.py index dcd8dceb2c..056defefb4 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 6096b10fd4..085150edec 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")