Kotlin / Kotlin/dataframe

Enable plugin interpretation of String overload functions

Open
#1,842 0 comments 2 reactions 0 assignees View on GitHub
Compiler plugin
Dominant language
Kotlin
Stars
1.1k
Forks
83
Avg merge
4d 12h
Merged PRs (30d)
30

Description

Examples of String overloads:
```kt
df.convert("a", "b")
df.move("a", "b")
df.group("a", "b")
```
and so on, total 57 in the library that i could find

String Column Accessors generally can be interpreted already:
```kt
val df = DataFrame.readJsonStr(""" {"a": 123, "b": "test"} """)
val df1 = df.select { "a"() and "b"() }
df1.a // DataColumn
```

This mechanism allows to easily "adapt" all "overloads" of APIs that already have support of ColumnsSelector overload.
For example:
```kt
@Refine
@Interpretable("Distinct0")
public fun DataFrame.distinct(columns: ColumnsSelector): DataFrame = select(columns).distinct()
```

What needs to be done:
```kt
/**
* Marks String API overloads (functions with vararg String parameters) with metadata
* to enable automatic delegation to their typed counterparts implementations in the compiler plugin.
*
* @param interpreter The interpreter name from the corresponding @Interpretable annotation
* on the typed API function (the one with ColumnSelectionDsl parameter)
* @param argumentMapping The name of the ColumnSelectionDsl parameter in the typed API function
*/
@Target(AnnotationTarget.FUNCTION)
public annotation class StringApiOverload(val interpreter: String, val argumentMapping: String)
```

Annotate function and don't forget `@Refine` if function returns schema-like value:
```kt
@Refine
@StringApiInterpretable(interpreter = "Distinct0", stringArgument = "columns")
public fun DataFrame.distinct(vararg columns: String): DataFrame = distinct { columns.toColumnSet() }
```

Motivation:
String overload APIs syntax is common for all dataframe libraries, likely to be used. It's bad that now plugin doesn't understand its usages and fallbacks to empty compiler time schema

Contributor guide

Open the contributing guide

Research direction

Start by locating the compiler-plugin handling for @Interpretable and @Refine, then inspect the String overloads such as distinct(vararg columns: String) and their typed ColumnSelectionDsl counterparts. Confirm the intended annotation naming, since the requested declaration is StringApiOverload while the example uses StringApiInterpretable, and verify that annotated overloads produce the typed schema instead of an empty compiler-time schema.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
compilers, data
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.