ArrowScan to_table fails if the data is mixed between dict-encoded strings and plain strings.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
Rechercherichtung
Beginne mit der minimalen Reproduktion und untersuche ArrowScan.to_table zusammen mit dem im Issue gezeigten to_record_batches-Einstiegspunkt. Überprüfe, wie Batches mit gemischten einfachen Strings und dictionary-kodierten Werten kombiniert werden. Als erledigt gilt die Aufgabe, wenn die Reproduktion ohne ArrowTypeError abgeschlossen wird und eine Arrow-Tabelle mit der erwarteten String-Spalte zurückgibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Apache Iceberg version
0.11.0 (latest release)
Please describe the bug 🐞
We have recently updated our functions to call the pyiceberg table.append() function with dict encoded arrow tables. Now we have in our iceberg tables mixed data from before this change, (where our data still is stored as string) and after the change, where the data is stored as dict-encoded strings.
If we now call to_arrow() of a DataScan class, on this table we get this error:
pyarrow.lib.ArrowTypeError: Unable to merge: Field col has incompatible types: string vs dictionary<values=string, indices=int32, ordered=0>
Here is a minimal example that reproduces this error:
from pyiceberg.io.pyarrow import ArrowScan
from pyiceberg.table import ALWAYS_TRUE
from pyiceberg.schema import Schema
from pyiceberg.types import NestedField
from pyiceberg.types import StringType
import pyarrow as pa
def create_scan_with_mixed_dict_encode_not_encode() -> ArrowScan:
schema = Schema(
NestedField(field_id=1, name="col", field_type=StringType(), required=False)
)
class FakeTableMetadata:
def schema(self) -> Schema:
return schema
scan = ArrowScan(table_metadata=FakeTableMetadata(),
io=object(),
projected_schema=schema,
row_filter=ALWAYS_TRUE)
def _batches_for_repro(self, _tasks):
str_values = pa.array(["a"], type=pa.string())
yield pa.record_batch([str_values], names=["col"])
yield pa.record_batch([str_values.dictionary_encode()], names=["col"])
ArrowScan.to_record_batches = _batches_for_repro
return scan
if __name__ == "__main__":
scan = create_scan_with_mixed_dict_encode_not_encode()
arrow_table = ArrowScan.to_table(scan, tasks=[])
I am happy to provide a bugfix PR, but I need a small guidance on the best approach.
One idea is to cast each batch in to_table to the arrow_schema. The more performant way is to check for each batch, if the schema is different. If they are different, then find the dict_encoded col and only cast that one to string.
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
- Vorherrschende Sprache
- Python
- Sterne
- 1.1k
- Forks
- 589
- Ø Merge
- 1 T. 20 Std.
- Gemergte PRs (30 T.)
- 68
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus apache/iceberg-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
apache/iceberg-python#4010 · 1 Reaktion ·
-
kind:bug
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
apache/iceberg-python#4006 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/iceberg-python#3996 ·
-
Deletion vector bitmap count is read from the blob and used as a loop bound without validation Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
apache/iceberg-python#3979 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
apache/iceberg-python#3885 ·
Alle Issues in apache/iceberg-python
Ähnliche Issues
-
agent-ready documentation needs-triage
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
-
documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 91/100
-
workflow-status page template still says reusable workflows are "triggered only by workflow_call:" Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
-
instance instance add
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
searxng/searx-instances#939 · 1 Kommentar ·
-
area-deployment area-integrations triage:bot-seen
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 86/100