`DataFrame.concat(rows)` drops the schema of a zero-row receiver

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

メンテナーはふだん 1 日以内に返信

@Kanish2002 がすでに取り組んでいます。

2026年10月11日 から。

評価

難易度
4/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
kotlin
領域
data

調査の方向性

Start from the DataFrame.concat(rows) implementation shown in the issue ((rows() + rows).concat()), which rebuilds from rows and therefore drops columns when the receiver is empty. Trace how empty frames (DataFrame.emptyOf) store schema versus how row-based concat unifies schemas. Add tests matching the acceptance criteria: empty iterable on emptyOf, and a zero-row receiver plus non-empty rows with a different runtime schema; keep existing non-empty-receiver unification unchanged.

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

説明

bug

Description

DataFrame.concat(rows: Iterable<DataRow<T>>) rebuilds the receiver from its rows:

public fun <T> DataFrame<T>.concat(rows: Iterable<DataRow<T>>): DataFrame<T> = (rows() + rows).concat()

Consequently, when the receiver has no rows, it contributes no columns to the result schema. The returned value still
has the static type DataFrame<T>, even though the runtime dataframe may no longer contain the columns declared by T.

How to reproduce

@DataSchema
interface BasicPerson {
    val name: String
    val age: Int
}

val df: DataFrame<BasicPerson> = dataFrameOf(
        "name" to columnOf("Alice", "Bob"),
        "age" to columnOf(20, 15),
    ).cast()

val emptyDf = DataFrame.emptyOf<BasicPerson>()
val result = emptyDf.concat(df.rows().take(0))

println(result.schema()) // []

println(result.age) // compiles, but fails at runtime with IllegalStateException (Column not found: 'age')

Expected behavior

The receiver should participate in schema unification even when it has no rows.

For the example above, result should:

  • contain zero rows;
  • preserve columns name and age;
  • have the same runtime schema as emptyDf.

Generally, the receiver's runtime schema should be preserved when rows are appended. If the iterable is non-empty, the result schema should be the union of the receiver's schema and the runtime schemas of the supplied rows.

Acceptance criteria

  • DataFrame.emptyOf<S>().concat(emptyList<DataRow<S>>()) preserves the runtime schema of the receiver.
  • A zero-row receiver contributes its columns when non-empty rows with a different runtime schema are appended.
  • The result contains the receiver rows first, followed by the supplied rows in their iteration order.
  • Existing schema-unification and missing-column behavior remains unchanged for non-empty receivers.
  • Tests cover both an empty supplied iterable and non-empty supplied rows.
主要言語
Kotlin
スター
1.1k
フォーク
87
平均マージ
2日 21時間
マージ済み PR(30日)
40

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

Kotlin/dataframe のほかの issue

Kotlin/dataframe の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

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

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