You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "grihabor (via GitHub)" <gi...@apache.org> on 2024/10/29 16:01:37 UTC
[I] ValueError: type(schema)=, but it must be pyiceberg.schema.Schema or pyarrow.Schema [iceberg-python]
grihabor opened a new issue, #1265:
URL: https://github.com/apache/iceberg-python/issues/1265
### Apache Iceberg version
0.7.1 (latest release)
### Please describe the bug 🐞
After updating pyarrow from 17.0.0 to 18.0.0, I've got this error:
```python
Traceback (most recent call last):
File "/home/grihabor/projects/playground/pyiceberg-pyarrow-schema/./run.py", line 38, in <module>
tbl = catalog.create_table(
^^^^^^^^^^^^^^^^^^^^^
File "/home/grihabor/projects/playground/pyiceberg-pyarrow-schema/.venv/pyarrow-18/lib/python3.12/site-packages/pyiceberg/catalog/sql.py", line 193, in create_table
schema: Schema = self._convert_schema_if_needed(schema) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/grihabor/projects/playground/pyiceberg-pyarrow-schema/.venv/pyarrow-18/lib/python3.12/site-packages/pyiceberg/catalog/__init__.py", line 732, in _convert_schema_if_needed
raise ValueError(f"{type(schema)=}, but it must be pyiceberg.schema.Schema or pyarrow.Schema")
ValueError: type(schema)=<class 'pyarrow.lib.Schema'>, but it must be pyiceberg.schema.Schema or pyarrow.Schema
```
### Steps to reproduce
`run.py` script:
```python
import shutil
from pyiceberg.catalog.sql import SqlCatalog
from pathlib import Path
import pyarrow as pa
warehouse_path = Path("/tmp/warehouse")
if warehouse_path.exists():
shutil.rmtree(warehouse_path)
Path(warehouse_path).mkdir()
catalog = SqlCatalog(
"default",
**{
"uri": f"sqlite:///{warehouse_path}/pyiceberg_catalog.db",
"warehouse": f"file://{warehouse_path}",
},
)
df = pa.Table.from_pylist(
mapping=[
{"city": "Amsterdam", "lat": 52.371807, "long": 4.896029},
{"city": "San Francisco", "lat": 37.773972, "long": -122.431297},
{"city": "Drachten", "lat": 53.11254, "long": 6.0989},
{"city": "Paris", "lat": 48.864716, "long": 2.349014},
],
schema=pa.schema(
[
("city", pa.large_string()),
("lat", pa.float64()),
("long", pa.float64()),
]
),
)
catalog.create_namespace("db")
tbl = catalog.create_table(
identifier="db.cities",
schema=df.schema,
)
tbl.overwrite(df)
print(tbl.scan().to_arrow())
```
This works:
```bash
uv venv --python 3.12 .venv/pyarrow-17
source .venv/pyarrow-17/bin/activate
uv pip install pyiceberg pyarrow==17.0.0 sqlalchemy
python ./run.py
```
This throws the exception:
```bash
uv venv --python 3.12 .venv/pyarrow-18
source .venv/pyarrow-18/bin/activate
uv pip install pyiceberg pyarrow==18.0.0 sqlalchemy
python ./run.py
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] pyarrow 18 regression: ValueError: type(schema)= [iceberg-python]
Posted by "grihabor (via GitHub)" <gi...@apache.org>.
grihabor commented on issue #1265:
URL: https://github.com/apache/iceberg-python/issues/1265#issuecomment-2448322124
Thanks for verifying, I've caught this in CI on dependabot update and reproduced it locally, I'll try to reproduce the problem in a docker container
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] pyarrow 18 regression: ValueError: type(schema)= [iceberg-python]
Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on issue #1265:
URL: https://github.com/apache/iceberg-python/issues/1265#issuecomment-2445614118
i was not able to reproduce on my local setup.
On `main` branch,
```
poetry add pyarrow==18.0.0
poetry run python run.py
```
I noticed that in your example, you've used `python` to run `./run.py`, perhaps you need to use
```
uv run python ./run.py
```
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [I] pyarrow 18 regression: ValueError: type(schema)= [iceberg-python]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko closed issue #1265: pyarrow 18 regression: ValueError: type(schema)=<class 'pyarrow.lib.Schema'>
URL: https://github.com/apache/iceberg-python/issues/1265
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org