Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

ArrowScan to_table fails if the data is mixed between dict-encoded strings and plain strings.

オープン
#3,260 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
databases

調査の方向性

最小再現から始め、issue に示されている to_record_batches エントリーポイントと併せて ArrowScan.to_table を調べます。プレーンな文字列と辞書エンコードされた値が混在するバッチがどのように結合されるかを確認します。再現が ArrowTypeError なしで完了し、期待される文字列列を持つ Arrow テーブルを返せば完了です。

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
Python
スター
1.1k
フォーク
589
平均マージ
2日 2時間
マージ済み PR(30日)
70

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/iceberg-python のほかの issue

apache/iceberg-python の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。