Skip to content

Support Java Record in toDataFrame conversion#1682

Open
koperagen wants to merge 1 commit intomasterfrom
record-conversion
Open

Support Java Record in toDataFrame conversion#1682
koperagen wants to merge 1 commit intomasterfrom
record-conversion

Conversation

@koperagen
Copy link
Collaborator

No description provided.

@koperagen koperagen added this to the 1.0.0-Beta5 milestone Feb 13, 2026
@koperagen koperagen self-assigned this Feb 13, 2026
@koperagen koperagen added the enhancement New feature or request label Feb 13, 2026
@koperagen koperagen linked an issue Feb 13, 2026 that may be closed by this pull request
options.release.set(16)
}

tasks.named<KotlinCompile>("compileTestKotlin") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This may be a slight issue, as this sets áll :core tests to java 16. We claim we support Java 8 for DataFrame, but we may not catch all issues correctly if we don't test with java 8. I found differences/bugs, for instance, with parsing certain Doubles in RTL locales which only occurred in Java 11, but not in 8 and the other way around.

Copy link
Collaborator

Choose a reason for hiding this comment

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

is there maybe a mechanism to only run java-record tests with jvm 16 while keeping the others at 8?

Copy link
Collaborator Author

@koperagen koperagen Feb 13, 2026

Choose a reason for hiding this comment

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

This goes both way, isn't it? we claim to support java 21 but don't test against it. I suggest, if we're interested, to specifically run tests compiled with JDK8 compatibility using JDK8, JDK17, JDK 21. Start with :core. It can be done

false
}

private val getRecordComponentsMethod: java.lang.reflect.Method? by lazy {
Copy link
Collaborator

@Jolanrensen Jolanrensen Feb 13, 2026

Choose a reason for hiding this comment

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

You can probably just import Method right? Or do you want to emphasize it's from Java? In that case I'd recommend importing it with the alias JavaMethod :) I do the same for Dates, Instants etc.

?.mapIndexed { i, v -> v to i }
?.toMap()
if (clazz.isJavaRecord) {
// Can fail for Java records with primitive types due to KT-58649
Copy link
Collaborator

Choose a reason for hiding this comment

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

interesting... Does it always fail? Otherwise, we could maybe catch the exception so the order is correct if it doesn't fail or the issue is fixed on the reflection side.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it always fails if there's a primitive type in the "constructor", like int. I'd wait until this is fixed on Kotlin side, logic would seem unstable + strange to reproduce it in the plugin (checking if there's a primitive..?)

* Sorts [this] according to the order of their [columnName] in the primary/single constructor of [klass]
* if it exists, else, it falls back to lexicographical sorting.
*/
internal fun <T> Iterable<KCallable<T>>.sortWithConstructor(klass: KClass<*>): List<KCallable<T>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I assume you removed this check for records? Maybe instead of removing it, you could skip the check only when dealing with a record

@Jolanrensen
Copy link
Collaborator

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Java Record in toDataFrame automatic converter

2 participants