Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order properties which are present in class primary constructor #32

Closed
ileasile opened this issue Jul 3, 2021 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@ileasile
Copy link
Contributor

ileasile commented Jul 3, 2021

We cannot infer the properties order in RT for this class:

class A {
    val x: Int
    val b: String
}

But we can do it for this class:

data class B(val x: Int, val b: String)

To achieve this, we may list primary constructor arguments names and map they to properties names:

KClass<*>.primaryConstructor?.parameters?.map { it.name }
@buckler4
Copy link

buckler4 commented Sep 18, 2021

@ileasile - agreed this enhancement would be great for toDataFrameByProperties. Additionally, I couldn't find a simple move method to order all the columns at once.

This works but not very elegant:

    var df= dataFrameRows.toDataFrameByProperties() as DataFrame<BKSamRecord>
    val colList: Array<String> = BKSamRecord::class.primaryConstructor?.parameters?.mapNotNull { it.name }!!.toTypedArray()
    val ordDf=df.move(*colList).toLeft()

ileasile pushed a commit that referenced this issue Dec 22, 2021
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

No branches or pull requests

2 participants