Skip to content

Commit a4a475a

Browse files
HonahXndrluis
andauthored
Imports decouple (#505) (#558)
Backport to 0.6.1 Co-authored-by: Andre Luis Anastacio <andreluisanastacio@gmail.com>
1 parent f0bb203 commit a4a475a

File tree

18 files changed

+27
-35
lines changed

18 files changed

+27
-35
lines changed

pyiceberg/catalog/glue.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
PREVIOUS_METADATA_LOCATION,
4747
TABLE_TYPE,
4848
Catalog,
49-
Identifier,
50-
Properties,
5149
PropertiesUpdateSummary,
5250
)
5351
from pyiceberg.exceptions import (
@@ -67,7 +65,7 @@
6765
from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table, update_table_metadata
6866
from pyiceberg.table.metadata import TableMetadata, new_table_metadata
6967
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
70-
from pyiceberg.typedef import EMPTY_DICT
68+
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
7169
from pyiceberg.types import (
7270
BinaryType,
7371
BooleanType,

pyiceberg/catalog/hive.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
METADATA_LOCATION,
6060
TABLE_TYPE,
6161
Catalog,
62-
Identifier,
63-
Properties,
6462
PropertiesUpdateSummary,
6563
)
6664
from pyiceberg.exceptions import (
@@ -79,7 +77,7 @@
7977
from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table, TableProperties, update_table_metadata
8078
from pyiceberg.table.metadata import new_table_metadata
8179
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
82-
from pyiceberg.typedef import EMPTY_DICT
80+
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
8381
from pyiceberg.types import (
8482
BinaryType,
8583
BooleanType,

pyiceberg/catalog/noop.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@
2828
from pyiceberg.table import (
2929
CommitTableRequest,
3030
CommitTableResponse,
31-
SortOrder,
3231
Table,
3332
)
34-
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER
33+
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
3534
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
3635

3736
if TYPE_CHECKING:

pyiceberg/catalog/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@
6464
CommitTableResponse,
6565
Table,
6666
TableIdentifier,
67-
TableMetadata,
6867
)
68+
from pyiceberg.table.metadata import TableMetadata
6969
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder, assign_fresh_sort_order_ids
7070
from pyiceberg.typedef import EMPTY_DICT, UTF8, IcebergBaseModel
7171

pyiceberg/catalog/sql.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
from pyiceberg.catalog import (
4545
METADATA_LOCATION,
4646
Catalog,
47-
Identifier,
48-
Properties,
4947
PropertiesUpdateSummary,
5048
)
5149
from pyiceberg.exceptions import (
@@ -64,7 +62,7 @@
6462
from pyiceberg.table import CommitTableRequest, CommitTableResponse, Table, update_table_metadata
6563
from pyiceberg.table.metadata import new_table_metadata
6664
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
67-
from pyiceberg.typedef import EMPTY_DICT
65+
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
6866

6967
if TYPE_CHECKING:
7068
import pyarrow as pa

pyiceberg/expressions/visitors.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
BoundStartsWith,
5555
BoundTerm,
5656
BoundUnaryPredicate,
57-
L,
5857
Not,
5958
Or,
6059
UnboundPredicate,
@@ -63,7 +62,7 @@
6362
from pyiceberg.manifest import DataFile, ManifestFile, PartitionFieldSummary
6463
from pyiceberg.partitioning import PartitionSpec
6564
from pyiceberg.schema import Schema
66-
from pyiceberg.typedef import EMPTY_DICT, StructProtocol
65+
from pyiceberg.typedef import EMPTY_DICT, L, StructProtocol
6766
from pyiceberg.types import (
6867
DoubleType,
6968
FloatType,

pyiceberg/io/pyarrow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@
7575
AlwaysTrue,
7676
BooleanExpression,
7777
BoundTerm,
78-
Literal,
7978
)
79+
from pyiceberg.expressions.literals import Literal
8080
from pyiceberg.expressions.visitors import (
8181
BoundBooleanExpressionVisitor,
8282
bind,

pyiceberg/table/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,15 @@
4545
from sortedcontainers import SortedList
4646
from typing_extensions import Annotated
4747

48+
import pyiceberg.expressions.parser as parser
49+
import pyiceberg.expressions.visitors as visitors
4850
from pyiceberg.exceptions import CommitFailedException, ResolveError, ValidationError
4951
from pyiceberg.expressions import (
5052
AlwaysTrue,
5153
And,
5254
BooleanExpression,
5355
EqualTo,
54-
parser,
55-
visitors,
5656
)
57-
from pyiceberg.expressions.visitors import _InclusiveMetricsEvaluator, inclusive_projection
5857
from pyiceberg.io import FileIO, load_file_io
5958
from pyiceberg.manifest import (
6059
POSITIONAL_DELETE_SCHEMA,
@@ -1293,7 +1292,9 @@ def _match_deletes_to_data_file(data_entry: ManifestEntry, positional_delete_ent
12931292
relevant_entries = positional_delete_entries[positional_delete_entries.bisect_right(data_entry) :]
12941293

12951294
if len(relevant_entries) > 0:
1296-
evaluator = _InclusiveMetricsEvaluator(POSITIONAL_DELETE_SCHEMA, EqualTo("file_path", data_entry.data_file.file_path))
1295+
evaluator = visitors._InclusiveMetricsEvaluator(
1296+
POSITIONAL_DELETE_SCHEMA, EqualTo("file_path", data_entry.data_file.file_path)
1297+
)
12971298
return {
12981299
positional_delete_entry.data_file
12991300
for positional_delete_entry in relevant_entries
@@ -1317,7 +1318,7 @@ def __init__(
13171318
super().__init__(table, row_filter, selected_fields, case_sensitive, snapshot_id, options, limit)
13181319

13191320
def _build_partition_projection(self, spec_id: int) -> BooleanExpression:
1320-
project = inclusive_projection(self.table.schema(), self.table.specs()[spec_id])
1321+
project = visitors.inclusive_projection(self.table.schema(), self.table.specs()[spec_id])
13211322
return project(self.row_filter)
13221323

13231324
@cached_property
@@ -1384,7 +1385,7 @@ def plan_files(self) -> Iterable[FileScanTask]:
13841385
# this filter depends on the partition spec used to write the manifest file
13851386

13861387
partition_evaluators: Dict[int, Callable[[DataFile], bool]] = KeyDefaultDict(self._build_partition_evaluator)
1387-
metrics_evaluator = _InclusiveMetricsEvaluator(
1388+
metrics_evaluator = visitors._InclusiveMetricsEvaluator(
13881389
self.table.schema(), self.row_filter, self.case_sensitive, self.options.get("include_empty_files") == "true"
13891390
).eval
13901391

tests/catalog/test_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
from pyiceberg.catalog import (
3232
Catalog,
33-
Identifier,
34-
Properties,
3533
PropertiesUpdateSummary,
3634
)
3735
from pyiceberg.exceptions import (
@@ -56,7 +54,7 @@
5654
from pyiceberg.table.metadata import TableMetadata, TableMetadataV1, new_table_metadata
5755
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
5856
from pyiceberg.transforms import IdentityTransform
59-
from pyiceberg.typedef import EMPTY_DICT
57+
from pyiceberg.typedef import EMPTY_DICT, Identifier, Properties
6058
from pyiceberg.types import IntegerType, LongType, NestedField
6159

6260

tests/catalog/test_rest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from requests_mock import Mocker
2424

2525
import pyiceberg
26-
from pyiceberg.catalog import PropertiesUpdateSummary, Table, load_catalog
26+
from pyiceberg.catalog import PropertiesUpdateSummary, load_catalog
2727
from pyiceberg.catalog.rest import AUTH_URL, RestCatalog
2828
from pyiceberg.exceptions import (
2929
NamespaceAlreadyExistsError,
@@ -35,6 +35,7 @@
3535
from pyiceberg.io import load_file_io
3636
from pyiceberg.partitioning import PartitionField, PartitionSpec
3737
from pyiceberg.schema import Schema
38+
from pyiceberg.table import Table
3839
from pyiceberg.table.metadata import TableMetadataV1
3940
from pyiceberg.table.sorting import SortField, SortOrder
4041
from pyiceberg.transforms import IdentityTransform, TruncateTransform

0 commit comments

Comments
 (0)