Skip to content

fix: create null-filled columns for remaining names in split into#1776

Merged
Jolanrensen merged 3 commits intoKotlin:masterfrom
Nidhi-M21:fix/split-into-null-columns
Mar 31, 2026
Merged

fix: create null-filled columns for remaining names in split into#1776
Jolanrensen merged 3 commits intoKotlin:masterfrom
Nidhi-M21:fix/split-into-null-columns

Conversation

@Nidhi-M21
Copy link
Copy Markdown

Fixes #1758

The fix was made in the splitImpl function in Split.kt.
When the number of explicit names exceeds the number of elements
in the list, null-filled collectors are now created for the remaining columns.

  • add null-filled columns when explicit names exceed list elements
  • add tests for null filled columns, exact elements, all empty lists and mixed lists

- add null-filled columns when explicit names exceed list elements
- add tests for null filled columns, exact elements, all empty lists and mixed lists
res["a2"][2] shouldBe null
res["a3"][2] shouldBe null
}
@Test
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please run ktlintFormat


repeat(names.size - columnCollectors.size) {
val collector = createDataCollector(nrow)
repeat(nrow) { collector.add(clause.default) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job using .default! That's even better than simply adding null. Could you add a test where this default is changed, though? with split { ... }.default("something")...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and use both String and lists in your tests :) so we cover them both

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added tests for both lists and strings as requested. Also ran ktlintFormat.

Cover custom default behavior for:
- Lists with missing values
- Empty lists
- String splitting with delimiter
- Cases where default is not used
@Nidhi-M21 Nidhi-M21 requested a review from Jolanrensen March 30, 2026 12:31
@Jolanrensen
Copy link
Copy Markdown
Collaborator

Jolanrensen commented Mar 31, 2026

Thanks! I've run our CI and all seems well

@Jolanrensen Jolanrensen merged commit 64943ed into Kotlin:master Mar 31, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

split into(vararg names) should create a null-filled column for remaining names if there's not enough values

4 participants