Skip to content

Example projects migration with compiler plugin#1734

Open
Jolanrensen wants to merge 6 commits intomasterfrom
youtube-example-separate-project
Open

Example projects migration with compiler plugin#1734
Jolanrensen wants to merge 6 commits intomasterfrom
youtube-example-separate-project

Conversation

@Jolanrensen
Copy link
Collaborator

@Jolanrensen Jolanrensen commented Mar 10, 2026

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

Helps #1614

@Jolanrensen Jolanrensen force-pushed the youtube-example-separate-project branch from 8c45513 to 69e4344 Compare March 10, 2026 13:02
@Jolanrensen Jolanrensen force-pushed the youtube-example-separate-project branch from 69e4344 to 106884e Compare March 13, 2026 14:39
@zaleslaw zaleslaw self-requested a review March 17, 2026 10:03
@Jolanrensen Jolanrensen marked this pull request as ready for review March 17, 2026 12:40
@Jolanrensen Jolanrensen added the examples Something related to the examples label Mar 17, 2026

val df = load("search?q=$searchRequest&maxResults=$resultsPerPage&part=snippet", maxPages)
df.schema()
.generateInterfaces("SearchResponse")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please try to re-generate the code, there should be an improvement!

* the compiler plugin can handle the rest.
*/
fun main() {
val id = "uHKfrz65KSU"
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it ok to have id here? is it video id?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe instead of ParsedStats use convert + with? temporarily

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

could work too. I don't think .convert { nameEndsWith("Count") } already works, right?

Copy link
Collaborator

@koperagen koperagen Mar 18, 2026

Choose a reason for hiding this comment

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

Looks like i made a silly mistake. What a shame lol
"NameEndsWith" -> NameEndsWith1()
image

image

Copy link
Collaborator

@koperagen koperagen Mar 18, 2026

Choose a reason for hiding this comment

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

change @Interpretable("NameEndsWith1") -> @Interpretable("NameEndsWith"), it'll work

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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>(
Copy link
Collaborator

Choose a reason for hiding this comment

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

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 }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

only downside is that it creates String? types

Copy link
Collaborator Author

@Jolanrensen Jolanrensen Mar 18, 2026

Choose a reason for hiding this comment

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

even if the list is not nullable... is that supposed to happen?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ahh, right
yes, if you split lists with different sizes then null values can appear, so we have to play safe

Copy link
Collaborator

Choose a reason for hiding this comment

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

another reason why we need specialized replace function :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

image

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

Labels

examples Something related to the examples

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants