From 8a20dc74bbe9e055c77ad0aa2f12bca7c90f6a6d Mon Sep 17 00:00:00 2001 From: Kuldeep Yadav Date: Fri, 25 Sep 2026 00:14:59 +0530 Subject: [PATCH] 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`. --- pyiceberg/table/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py index ac67e3187f..9a2808069f 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -33,7 +33,6 @@ from pydantic import Field -import pyiceberg.expressions.parser as parser from pyiceberg.exceptions import CommitFailedException, ValidationException from pyiceberg.expressions import AlwaysFalse, AlwaysTrue, And, BooleanExpression, EqualTo, IsNull, Or, Reference from pyiceberg.expressions.visitors import ( @@ -2042,6 +2041,8 @@ def _parse_row_filter(expr: str | BooleanExpression) -> BooleanExpression: Returns: An unbound BooleanExpression. """ + from pyiceberg.expressions import parser + return parser.parse(expr) if isinstance(expr, str) else expr