Example projects migration with compiler plugin#1734
Example projects migration with compiler plugin#1734Jolanrensen wants to merge 6 commits intomasterfrom
Conversation
8c45513 to
69e4344
Compare
…ler plugin enabled
69e4344 to
106884e
Compare
…mpiler plugin enabled
...ovies/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/movies/moviesWithInterface.kt
Show resolved
Hide resolved
...ovies/src/main/kotlin/org/jetbrains/kotlinx/dataframe/examples/movies/moviesWithInterface.kt
Show resolved
Hide resolved
|
|
||
| val df = load("search?q=$searchRequest&maxResults=$resultsPerPage&part=snippet", maxPages) | ||
| df.schema() | ||
| .generateInterfaces("SearchResponse") |
There was a problem hiding this comment.
Please try to re-generate the code, there should be an improvement!
| * the compiler plugin can handle the rest. | ||
| */ | ||
| fun main() { | ||
| val id = "uHKfrz65KSU" |
There was a problem hiding this comment.
is it ok to have id here? is it video id?
There was a problem hiding this comment.
yeah, it is... maybe I could generate it from taking the first result in the search response
| // TODO replace with requireColumn {} when available | ||
| // parse cannot know what type the columns will be at runtime, | ||
| // so we need to cast the columns ourselves. | ||
| .cast<ParsedStats>(verify = true) |
There was a problem hiding this comment.
maybe instead of ParsedStats use convert + with? temporarily
There was a problem hiding this comment.
could work too. I don't think .convert { nameEndsWith("Count") } already works, right?
There was a problem hiding this comment.
change @Interpretable("NameEndsWith1") -> @Interpretable("NameEndsWith"), it'll work
There was a problem hiding this comment.
alright! however then there will be a difference between the dev and the release version. Which is fine :) that's why we have two versions
| .split { genres }.by("|").inplace() | ||
| // TODO replace with `requireColumn {}` #1715 or replace+AddDsl #1749 | ||
| .split { title }.by { | ||
| listOf<Any>( |
There was a problem hiding this comment.
Thought of an another approach. Split List and perform convert later
listOf(
"""\s*(\d{4})\s*$""".toRegex().replace(title, ""),
"\d{4}".toRegex().findAll(title).lastOrNull()?.value ?: "",
)
and later
convert { year }.with { it.toIntOrNull() ?: -1 }
There was a problem hiding this comment.
only downside is that it creates String? types
There was a problem hiding this comment.
even if the list is not nullable... is that supposed to happen?
There was a problem hiding this comment.
ahh, right
yes, if you split lists with different sizes then null values can appear, so we have to play safe
There was a problem hiding this comment.
another reason why we need specialized replace function :)



moving youtube and movies example projects to /examples/projects(/dev) with compiler plugin enabled
Helps #1614