Skip to content

Commit f7dcc3d

Browse files
authored
perf(table): import the expression parser lazily (#4012)
Import the expression parser lazily in pyiceberg.table The parser is only used by _parse_row_filter for string row filters, but importing it at module level pulls in pyparsing (and unittest, argparse and difflib through pyparsing.testing) on every `import pyiceberg.table` and `load_catalog`.
1 parent a46cbdf commit f7dcc3d

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎pyiceberg/table/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333

3434
from pydantic import Field
3535

36-
import pyiceberg.expressions.parser as parser
3736
from pyiceberg.exceptions import CommitFailedException, ValidationException
3837
from pyiceberg.expressions import AlwaysFalse, AlwaysTrue, And, BooleanExpression, EqualTo, IsNull, Or, Reference
3938
from pyiceberg.expressions.visitors import (
@@ -2042,6 +2041,8 @@ def _parse_row_filter(expr: str | BooleanExpression) -> BooleanExpression:
20422041
20432042
Returns: An unbound BooleanExpression.
20442043
"""
2044+
from pyiceberg.expressions import parser
2045+
20452046
return parser.parse(expr) if isinstance(expr, str) else expr
20462047

20472048

0 commit comments

Comments
 (0)