-
Notifications
You must be signed in to change notification settings - Fork 73
[Compiler plugin] Support dataFrameOf(Pair<String, List<T>) #908
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
13 changes: 13 additions & 0 deletions
13
plugins/kotlin-dataframe/src/org/jetbrains/kotlinx/dataframe/plugin/impl/api/stdlib.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.jetbrains.kotlinx.dataframe.plugin.impl.api | ||
|
||
import org.jetbrains.kotlinx.dataframe.plugin.impl.AbstractInterpreter | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.Arguments | ||
import org.jetbrains.kotlinx.dataframe.plugin.impl.Interpreter | ||
|
||
class PairConstructor : AbstractInterpreter<Pair<*, *>>() { | ||
val Arguments.receiver: Any? by arg(lens = Interpreter.Id) | ||
val Arguments.that: Any? by arg(lens = Interpreter.Id) | ||
override fun Arguments.interpret(): Pair<*, *> { | ||
return receiver to that | ||
} | ||
} |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import org.jetbrains.kotlinx.dataframe.* | ||
import org.jetbrains.kotlinx.dataframe.annotations.* | ||
import org.jetbrains.kotlinx.dataframe.api.* | ||
import org.jetbrains.kotlinx.dataframe.io.* | ||
|
||
fun box(): String { | ||
val df = dataFrameOf( | ||
"a" to listOf(1, 2), | ||
"b" to listOf("str1", "str2"), | ||
) | ||
val i: Int = df.a[0] | ||
val str: String = df.b[0] | ||
return "OK" | ||
} |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so.. does this mean it fails for
dataFrameOf(Pair("name", listOf(1, 2, 3)))
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably fine, most people will use
to
anyway, but it might be something we should mention in a doc somewhere, for that one person who's going to be very confused as to why their Pair is not recognized by the plugin if the function only accepts pairs as the type argument.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let's support Pair after i put in place more generic way for handling stdlib functions other than "if". And indeed with such things it's much easier to run into something plugin won't understand. One of the things that can be addressed with custom Checker that will highlight it as warning