`toList()` and `toSequence()` throw with the compiler plugin right after `toDataFrame()`

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

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

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

評価

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

調査の方向性

Read ToListSamples in samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/collectionsInterop/ (the two compiler-plugin cases) and the KDocs plus Interop with Collections docs for toList/toSequence. The failure is that the plugin substitutes a generated type after toDataFrame/add so toList cannot instantiate it. Do not pick an option (deprecate, change the plugin in the Kotlin repo, or a clearer error) until maintainers decide; this is not a one-file first issue.

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

説明

bug Compiler plugin

What happens

With the Kotlin DataFrame compiler plugin, toDataFrame() on a list of data class instances gives the
result a generated type argument instead of the original class. toList() then tries to create instances
of that generated type, which is not a data class, and throws:

data class Input(val a: Int, val b: Int)

val df = listOf(Input(1, 2)).toDataFrame()

df.toList()
// IllegalArgumentException: `class ...$Input_48` is not a data class.
// `toList`, `toListOf`, `toSequence` and `toSequenceOf` support only data classes.

The same happens after other operations the plugin refines, for example add. Declaring the type
explicitly does not help either:

val df: DataFrame<Input> = listOf(Input(1, 2)).toDataFrame()
// INITIALIZER_TYPE_MISMATCH: expected 'DataFrame<Input>', actual 'DataFrame<Input_48>'

Today the only ways out are df.toListOf<Input>() and df.cast<Input>().toList(). With the plugin,
almost every dataframe has a generated type argument, so toList() and toSequence() are hardly
usable in such projects.

Options

  1. Deprecate toList()/toSequence() in favour of toListOf<T>()/toSequenceOf<T>().
  2. Make the compiler plugin keep the original class as the type argument after toDataFrame()
    (needs a change in the plugin, in the Kotlin repository).
  3. Give a clearer error message when the type argument is a plugin-generated type, pointing to
    toListOf.

Tests

ToListSamples in samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/samples/api/collectionsInterop/
pins the current behaviour:
with the compiler plugin toList throws right after toDataFrame and
with the compiler plugin toList throws after add. The KDocs of toList/toSequence and the toList
and "Interop with Collections" pages describe it; update them when this is fixed.

主要言語
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 を短くまとめたダイジェスト。