-
Notifications
You must be signed in to change notification settings - Fork 393
Add ResidualVisitor to compute residuals #1388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…y-op add count in data scan and test in catalog sql
|
Question: Does it make sense to expose this as the |
Residual Evaluator with test
* added residual evaluator in plan files * tested counts with positional deletes * merged main
* added residual evaluator in plan files * tested counts with positional deletes * merged main * implemented batch reader in count * breaking integration test * fixed integration test * git pull main * revert * revert * revert test_partitioning_key.py * revert test_parser.py * added residual evaluator in visitor * deleted residual_evaluator.py * removed test count from test_sql.py * ignored lint type * fixed lint * working on plan_files * type ignored * make lint
|
Hi @Fokko @kevinjqliu @gli-chris-hao , I have implemented these suggestions with my best understanding.
It would be helpful to get fresh review |
* added residual evaluator in plan files * tested counts with positional deletes * merged main * implemented batch reader in count * breaking integration test * fixed integration test * git pull main * revert * revert * revert test_partitioning_key.py * revert test_parser.py * added residual evaluator in visitor * deleted residual_evaluator.py * removed test count from test_sql.py * ignored lint type * fixed lint * working on plan_files * type ignored * make lint * explicit delete files len is zero * residual eval only if manifest is true * default residual is always true * used projection schema * refactored residual in plan files * fixed lint issue with isnan * simplified count if else conditions * implemented refactoring comments on residual visitor
Sometime I'm seeing this:
```
ImportError while loading conftest '/home/runner/work/iceberg-python/iceberg-python/tests/conftest.py'.
tests/conftest.py:52: in <module>
from pyiceberg.catalog import Catalog, load_catalog
pyiceberg/catalog/__init__.py:51: in <module>
from pyiceberg.serializers import ToOutputFile
pyiceberg/serializers.py:25: in <module>
from pyiceberg.table.metadata import TableMetadata, TableMetadataUtil
pyiceberg/table/__init__.py:65: in <module>
from pyiceberg.io.pyarrow import ArrowScan, schema_to_pyarrow
pyiceberg/io/pyarrow.py:141: in <module>
from pyiceberg.table.locations import load_location_provider
pyiceberg/table/locations.py:25: in <module>
from pyiceberg.table import TableProperties
E ImportError: cannot import name 'TableProperties' from partially initialized module 'pyiceberg.table' (most likely due to a circular import) (/home/runner/work/iceberg-python/iceberg-python/pyiceberg/table/__init__.py)
```
Also observed in: apache#1388
I prefer the imports at the top, but I think this is a small price
to pay to avoid having circular imports.
Sometime I'm seeing this:
```
ImportError while loading conftest '/home/runner/work/iceberg-python/iceberg-python/tests/conftest.py'.
tests/conftest.py:52: in <module>
from pyiceberg.catalog import Catalog, load_catalog
pyiceberg/catalog/__init__.py:51: in <module>
from pyiceberg.serializers import ToOutputFile
pyiceberg/serializers.py:25: in <module>
from pyiceberg.table.metadata import TableMetadata, TableMetadataUtil
pyiceberg/table/__init__.py:65: in <module>
from pyiceberg.io.pyarrow import ArrowScan, schema_to_pyarrow
pyiceberg/io/pyarrow.py:141: in <module>
from pyiceberg.table.locations import load_location_provider
pyiceberg/table/locations.py:25: in <module>
from pyiceberg.table import TableProperties
E ImportError: cannot import name 'TableProperties' from partially initialized module 'pyiceberg.table' (most likely due to a circular import) (/home/runner/work/iceberg-python/iceberg-python/pyiceberg/table/__init__.py)
```
Also observed in: #1388
I prefer the imports at the top, but I think this is a small price to
pay to avoid having circular imports.
Fokko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def test_fokko(session_catalog):
import pyarrow.parquet as pq
df = pq.read_table("/Users/fokko.driesprong/Downloads/yellow_tripdata_2024-01.parquet")
session_catalog.drop_table("default.taxis")
tbl = session_catalog.create_table("default.taxis", schema=df.schema)
with tbl.update_spec() as spec:
spec.add_field("tpep_pickup_datetime", DayTransform())
tbl.append(df)
# tbl = session_catalog.load_table("default.taxis")
pred = LessThan("tpep_pickup_datetime", datetime.datetime(2024, 1, 3, 12, 0, 0))
cnt = tbl.scan(row_filter=pred).count()
assert cnt == len(df.filter(expression_to_pyarrow(pred.bind(tbl.schema()))))Works very well:
|
Thanks @tusharchou for working on this 🚀 |
|
🚀 |
closes issue: Count rows as a metadata-only operation #1223