Upsert fails after update_schema().union_by_name() due to schema mismatch
Mantenedores costumam responder em até 1 dia
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 68/100
Direção de pesquisa
Comece em pyiceberg/table/upsert_util.py, em get_rows_to_update, depois siga o caminho table.upsert em pyiceberg/table/init.py e a chamada pyarrow Table.cast que está falhando. Execute a reprodução fornecida com a versão 0.10.0 e adicione cobertura de regressão mostrando que upsert é bem-sucedido depois que union_by_name adiciona ping, preservando o schema atualizado.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Apache Iceberg version
0.10.0
Please describe the bug 🐞
When performing an upsert operation after adding a new column via update_schema().union_by_name() , the operation fails with a ValueError indicating that the schema field names don't match.
To reproduce:
from pyiceberg.catalog import load_catalog
import polars as pl
catalog = load_catalog("default", **{"type": "in-memory"})
df = pl.DataFrame(
[
{"id": 1, "name": "Alice", "age": 30, "city": "São Paulo"},
{"id": 2, "name": "Bob", "age": 25, "city": "Rio de Janeiro"},
{"id": 3, "name": "Carol", "age": 35, "city": "Belo Horizonte"},
{"id": 4, "name": "David", "age": 28, "city": "Curitiba"},
]
)
arrow = df.to_arrow()
catalog.create_namespace_if_not_exists("default")
catalog.create_table_if_not_exists("default.my_table", arrow.schema)
table = catalog.load_table("default.my_table")
try:
table.append(arrow)
# Add a new column
arrow = df.with_columns(ping=pl.lit("pong")).to_arrow()
# Update schema to include the new column
with table.update_schema() as update_schema:
update_schema.union_by_name(arrow.schema)
table = table.refresh()
# This fails with ValueError
table.upsert(arrow, ["id"])
finally:
catalog.drop_table("default.my_table")
Error:
ValueError: Target schema's field names are not matching the table's field names: ['id', 'name', 'age', 'city', 'ping'], ['id', 'name', 'age', 'city']
Stack trace:
File "pyiceberg/table/__init__.py", line 1343, in upsert
return tx.upsert(
File "pyiceberg/table/__init__.py", line 825, in upsert
rows_to_update = upsert_util.get_rows_to_update(df, rows, join_cols)
File "pyiceberg/table/upsert_util.py", line 92, in get_rows_to_update
source_table.cast(target_table.schema)
File "pyarrow/table.pxi", line 4721, in pyarrow.lib.Table.cast
Expected:
The upsert operation should succeed after the schema has been updated to include the new column.
Willingness to contribute
- I can contribute a fix for this bug independently
- I would be willing to contribute a fix for this bug with guidance from the Iceberg community
- I cannot contribute a fix for this bug at this time
- Linguagem predominante
- Python
- Estrelas
- 1.2k
- Forks
- 618
- Merge médio
- 1d 13h
- PRs com merge (30d)
- 47
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de apache/iceberg-python
-
CLI: --output=json list-refs emits one object per retention property instead of per refTalvez já em andamento @tomron assumiu hoje. Abertakind:bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 87/100
apache/iceberg-python#4098 ·
Mantenedores costumam responder em até 1 dia
-
REST: Send empty first-page pageToken when rest-page-size is setTalvez já em andamento @ehddnr301 assumiu hoje. Abertakind:bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
apache/iceberg-python#4096 ·
Mantenedores costumam responder em até 1 dia
-
PyArrowFileIO: every small S3 write is a 3-request multipart upload; expose allow_delayed_openAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/iceberg-python#4093 ·
Mantenedores costumam responder em até 1 dia
-
View does not expose metadata_location: RestCatalog.load_view discards it from the server's responseTalvez já em andamento @Soumo-git-hub assumiu há 5 dias. Abertakind:bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
apache/iceberg-python#4073 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
apache/iceberg-python#4010 · 3 comentários · 1 reação ·
Mantenedores costumam responder em até 1 dia
Todas as issues de apache/iceberg-python
Issues semelhantes
-
bug
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 88/100
openwisp/openwisp-utils#777 ·
-
Boolean statistics (Covered, Confident, JaccardDistant) aggregate to 1.0 without float weightsAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 63/100
google-research/weatherbenchX#310 ·
Mantenedores costumam responder em até 3 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
huggingface/peft#3955 ·
Mantenedores costumam responder em até 1 dia
-
author-page correction
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 60/100
acl-org/acl-anthology#10313 ·
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
AOSSIE-Org/Gitcord-GithubDiscordBot#147 · 1 comentário ·
Mantenedores costumam responder em até 1 dia