Skip to content

Split move {}.toTop {} into toTop {} and toTop() for correct compiler plugin support #1508

@Jolanrensen

Description

@Jolanrensen

We have

@Refine
@Interpretable("ToTop")
public fun <T, C> MoveClause<T, C>.toTop(
    newColumnName: ColumnsSelectionDsl<T>.(ColumnWithPath<C>) -> String = { it.name() },
): DataFrame<T> = into { newColumnName(it).toColumnAccessor() }

However, no matter how it's called, the compiler plugins calls toTop { it.name() }.

Meaning, if a user specifies newColumnName like move { group.col }.toTop { it.name() + "1" } .col is available on the result, but at will fail at runtime as there's only the "col1" column.

We cannot reliably see what's inside this lambda expression (unless we follow rename { singleCol }.into { "string constant" }), so it may be best to split it:

@Refine
@Interpretable("ToTop")
public fun <T, C> MoveClause<T, C>.toTop(): DataFrame<T> = toTop { it.name() }

public fun <T, C> MoveClause<T, C>.toTop(
    newColumnName: ColumnsSelectionDsl<T>.(ColumnWithPath<C>) -> String,
): DataFrame<T> = into { newColumnName(it).toColumnAccessor() }

This doesn't even need changes in the compiler plugin AFAIK :)

Metadata

Metadata

Assignees

Labels

Compiler pluginAnything related to the DataFrame Compiler PluginbugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions