Added KDocs, tests and website examples for unfold, fixed DataColumn.unfold - #2117
Merged
Merged
Conversation
This commit introduces extensive examples and tests for the `unfold` API, showcasing its usage in various scenarios like unfolding column groups, nested objects, frame columns, and handling edge cases. Documentation resources and shadow resources have also been updated to reflect these additions.
Contributor
There was a problem hiding this comment.
Looks great — approving.
Produced by Air Automations. Name: AI Review / Run: https://air.jetbrains.cloud/org/05cf1a7f-6ab5-713b-abd3-29d0c8a05e2d/automations/8daf2412-0b6c-4433-90c0-b40ab5aebcdb?run=0cfd6ff6-2c80-468e-9930-696ac4f9b56d
koperagen
reviewed
Sep 30, 2026
koperagen
reviewed
Sep 30, 2026
koperagen
reviewed
Sep 30, 2026
zaleslaw
marked this pull request as ready for review
October 1, 2026 13:44
…ests and documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1991
unfoldhad no KDocs, its page had one example with adata: Anyclass, and two of three overloads had no tests.This PR documents the three non-deprecated overloads, rewrites the page on the
toDataFramedataset, and fixesDataColumn.unfoldon untyped columns.Files
core/.../api/unfold.ktUnfoldDocscore/.../impl/api/unfold.ktDataColumn.unfoldfalls back to the column type whenTcannot be unfoldedcore/.../documentation/DocumentationUrls.ktUnfoldlinkcore/src/test/.../api/unfold.kt@Ignored tests for #2114samples/.../api/UnfoldSamples.kt,topics/unfold.mdunfold,maxDepth,roots, what stays as it is,unfoldonDataColumn. Removed: theRepositoryInfoexample, the "useful when" list and "a special case ofconvert" (see the note)samples/.../plugin/UnfoldCompileTimeSchemaTests.ktunfoldandtoDataFrame; 3@Ignored tests for #2114 and #2115topics/_shadow_resources.md,resources/api/unfold/,samples/build.gradle.kts:sampleskorrotopics/collectionsInterop.md,topics/updateConvert.mdunfoldreworded to match the KDocExamples
The page, the KDocs and the tests use the classes and objects of the
toDataFrame()example oncreateDataFrame.md(Student,Name,Score), sounfold(maxDepth = 1)shows the same structure astoDataFrame(maxDepth = 1)there.Tests
Before, only the
DataFrameoverloads with default arguments andmaxDepthwere tested. All expected values come from a real run.maxDepth0 / 1 / 2rootsAny, column groups, frame columnsnullobjects, several columns by nameDataColumn.unfoldAnyfalls back to the column type; the same column is returned when it cannot be unfoldedNote for the reviewer
df["student"].unfold()(static typeAny?) returned a column group with one columnvalueholding the objects. Now it unfolds the objects by the column type. Test:DataColumn unfold reads the properties of the values when the static type is Any. The fallback lives inunfoldImpl, which is not inline, so already compiled callers get it too. ADataColumn<Supertype>still unfolds only the properties of the supertype.rootsare ignored on a column of simple values (unfold(String::length) { word }keeps the column); withroots, the compiler plugin derives an empty schema (Kotlin DataFrame plugin:unfoldandtoDataFramewith properties give an empty schema #2115).@IgnorewithTODO(#2114)/TODO(#2115): roots of another class are stored as exceptions; a column of lists becomes{ size }; a column of maps is unfolded; with property roots the compiler plugin derives an empty schema forunfoldandtoDataFrame.unfold.md: theRepositoryInfoexample. Its class had one property,data: Any, so the result was a group with oneAnycolumn and showed neither nesting,maxDepthnorroots; its use case ("a library API gives you class instances") is kept as a sentence. The item "you do not want to or cannot annotate classes with@DataSchema" is removed because annotating does not change anything here:columnOfanddataFrameOfkeep@DataSchemaobjects in aValueColumn, like any other objects. "It's a special case ofconvert" moved to "See also" asconvertandreplace.core/.../samples/api/Modify.ktkeeps the oldconvertToColumnGroup*samples; no page uses them anymore.