Skip to content
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

Compiler plugin #729

Merged
merged 339 commits into from
Jun 12, 2024
Merged

Compiler plugin #729

merged 339 commits into from
Jun 12, 2024

Conversation

koperagen
Copy link
Collaborator

@koperagen koperagen commented Jun 10, 2024

There are changes in core module itself to be aware of:

  1. DataRowApi.kt is related to Generate constructor for schema interface #113. Compiler plugin automatically adds DataRowSchema as a supertype to data schemas, enabling those APIs. To be continued later
  2. Changes in insert.kt. An attempt to make it work over a generic tree, in order to share implementation between compiler plugin and core library
  3. Across library added annotations that provide required meta information for compiler plugin
  4. aggregate, toDataFrame functions user to be member functions in Grouped, GroupBy interfaces. Now they are extension functions, in order for plugin to work + it's not clear why they should be member function after all

Compiler plugin module consists of three main parts:

  1. Plugin that generates extension properties, that will replace KSP plugin as it generates declarations in IDE without running a Gradle task. Related to Enhance support for @DataSchema in gradle projects #120
  2. Plugin that adds DataRowSchema supertype to a data schema annotated declarations.
  3. Most importantly, plugin that makes it possible to elevate compile time information from function arguments to type level. Plugin updates types of DataFrame objects whenever supported (=annotated with Refine) function is called with constant arguments. Most of the code here is its implementation

Everything related to compiler plugins aimed at K2 compiler
#704

…only for private api

Initializing non-private property with transformed DataFrame call leads to "exposes local type" error
# Conflicts:
#	core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/and.kt
#	core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/api/toDataFrame.kt
@koperagen koperagen merged commit cf234e7 into master Jun 12, 2024
2 checks passed
@@ -18,7 +19,7 @@ import kotlin.reflect.KType
*
* @param T type of values contained in column.
*/
public interface BaseColumn<out T> : ColumnReference<T> {
public interface BaseColumn<out T> : ColumnReference<T>, GenericColumn {
Copy link
Collaborator

@Jolanrensen Jolanrensen Jun 13, 2024

Choose a reason for hiding this comment

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

@koperagen GenericColumn?
It's fine to have the interface as its supertype to just get the name of a column, but it lives in ./impl/api/insert.kt which breaks our structure. Probably best to move GenericColumn(Group) to ./columns

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah I see it's mentioned in the comment! thanks


data class SimpleFrameColumn(
override val name: String,
private val columns: List<SimpleCol>
Copy link
Collaborator

@Jolanrensen Jolanrensen Jun 13, 2024

Choose a reason for hiding this comment

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

If SimpleColumnGroup is a List<SimpleColumn>, then SimpleFrameColumn should be a List<List<SimpleColumn>> or a List<ColumnGroup> right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah no I see, it treats it like that because it tries to generalize the schema's, interesting

import kotlin.reflect.KTypeProjection
import kotlin.reflect.KVariance

val KotlinTypeFacade.toPluginDataFrameSchema: DataFrameSchema.() -> PluginDataFrameSchema
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice! very useful :)

name,
columnSchema.schema.toPluginDataFrameSchema().columns()
)
else -> TODO()
Copy link
Collaborator

Choose a reason for hiding this comment

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

probably throw a NotImplementedError manually to not clog up the TODO scope

@koperagen koperagen self-assigned this Jun 17, 2024
@Jolanrensen Jolanrensen added the Compiler plugin Anything related to the DataFrame Compiler Plugin label Aug 8, 2024
@koperagen koperagen deleted the compiler-plugin branch August 26, 2024 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compiler plugin Anything related to the DataFrame Compiler Plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants