Kotlin DataFrame plugin: `unfold` and `toDataFrame` with properties give an empty schema
Maintainer thường phản hồi trong vòng 1 ngày
@koperagen đang làm issue này rồi.
Từ ngày 29/9/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
When DataFrame.unfold or Iterable.toDataFrame get a list of properties, the plugin derives an empty
schema for the result. At runtime the result has columns, and none of them can be accessed through the
generated accessors.
Reproduce
data class Name(val firstName: String, val lastName: String)
data class Score(val subject: String, val value: Int)
data class Student(val name: Name, val age: Int, val scores: List<Score>)
val df = dataFrameOf(
"id" to listOf(1, 2),
"student" to listOf(
Student(Name("Alice", "Cooper"), 15, listOf(Score("math", 4), Score("biology", 3))),
Student(Name("Bob", "Marley"), 20, listOf(Score("music", 5))),
),
"year" to listOf(2021, 2022),
)
val unfolded = df.unfold(Student::name, Student::age) { student }
unfolded.compileTimeSchema() // empty
unfolded.schema() // id: Int, student: { name: Name, age: Int }, year: Int
val fromList = listOf(Student(Name("Alice", "Cooper"), 15, emptyList())).toDataFrame(Student::age)
fromList.compileTimeSchema() // empty
fromList.schema() // age: Int
Without properties the schemas match: df.unfold(maxDepth = 1) { student } and toDataFrame() give the same
schema at compile time and at runtime. The tests for both cases are in Kotlin/dataframe,
samples/src/test/kotlin/org/jetbrains/kotlinx/dataframe/plugin/UnfoldCompileTimeSchemaTests.kt
(issue 1, case 5): unfold with roots … and toDataFrame with properties …, both @Ignored.
What we see in the source
DataFrameUnfold(kotlin-dataframe.k2/.../impl/api/unfold.kt) declaresval Arguments.properties by ignore(),
but the parameter ofDataFrame.unfoldis calledroots.ToDataFrame(.../impl/api/toDataFrame.kt) does not declare thepropsparameter of
Iterable.toDataFrame(vararg props: KProperty<*>, maxDepth: Int)at all.
We think the interpreters cannot match the vararg argument, so the interpretation fails and the plugin falls
back to an empty schema. We did not confirm this in the plugin itself.
Suggested fix
Read the property references the way Exclude1 and Preserve1 already do, and keep only the columns for
those properties:
class DataFrameUnfold : AbstractSchemaModificationInterpreter() {
val Arguments.receiver: PluginDataFrameSchema by dataFrame()
val Arguments.roots: FirVarargArgumentsExpression by arg(lens = Interpreter.Id)
val Arguments.maxDepth: Int by arg(defaultValue = Present(0))
val Arguments.columns: ColumnsResolver by arg()
override fun Arguments.interpret(): PluginDataFrameSchema {
val rootNames = roots.arguments
.filterIsInstance<FirCallableReferenceAccess>()
.map { it.calleeReference.name.identifier }
return receiver.modify(impliedColumnsResolver = columns) {
replace { columns }.with {
val column = it.asSimpleColumn() as? SimpleDataColumn
if (column == null || !column.type.coneType.canBeUnfolded(session)) {
it
} else {
val unfolded = toDataFrame(maxDepth, column.type.coneType, TraverseConfiguration.EMPTY).columns()
val kept = if (rootNames.isEmpty()) unfolded else unfolded.filter { col -> col.name in rootNames }
SimpleColumnGroup(it.name(), kept).asDataColumn()
}
}
}
}
}
This is a sketch: we did not compile it. Two things to check:
- how a missing vararg argument is passed (the default is no roots);
- that the column name is the property name. It is not for
@ColumnNameproperties and for getters like
getX(), so it is safer to filter by the property symbol than by the name.
ToDataFrame needs the same change for props.
Changes to make together with Kotlin/dataframe #2114
When the library fixes land, the plugin has to change in the same release, or the compile-time schema will
differ from the runtime one:
- roots on a column of simple values (issue 1, case 1): when roots are given, do not return the column
unchanged just becausecanBeUnfoldedisfalsefor its type. - a column of lists of objects (issue 1, case 3): derive a
SimpleFrameColumnfrom the element type
instead of a column group withsize. - maps (issue 1, case 4):
isValueTypematchesStandardClassIds.Map/MutableMapexactly. Match
subtypes ofMap, so that it stays aligned with the library'sKClass.isValueType.
- Ngôn ngữ chính
- Kotlin
- Star
- 1.1k
- Fork
- 87
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Kotlin/dataframe
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add `columnOf(vararg DataFrame<T: DataRowSchema>): FrameColumn<T>` overload for compatibilityĐang mởAPI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Kotlin/dataframe#2202 · 3 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Kotlin/dataframe#2195 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AX
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Add minimal KDocs for `print` APIsCó thể đã có người làm @zaleslaw đã nhận 4 ngày trước. Đang mởKDocs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Kotlin/dataframe
Issue tương tự
-
[Submission] 招商银行Đang mởsubmit-adaption submit-adaption-pre
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
BetterAndroid/android-notification-icon-project#848 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
"Tick" is confusingĐang mởbug
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 70/100
orgzly-revived/orgzly-android-revived#1132 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
commons-app/apps-android-commons#7275 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
liberation-data/drivine4j#682 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
developmentwithyash/yaan#14 ·
Maintainer thường phản hồi trong vòng 2 ngày