Skip to content

Refactor toDataFrame implementation in compiler plugin #782

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

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

koperagen
Copy link
Collaborator

No description provided.

@koperagen koperagen added this to the 0.14.0 milestone Jul 16, 2024
@koperagen koperagen self-assigned this Jul 16, 2024
@@ -161,6 +164,9 @@ internal inline fun <reified T> String.load(): T {
"ReadDelimStr" -> ReadDelimStr()
"GroupByToDataFrame" -> GroupByToDataFrame()
"ToDataFrameFrom0" -> ToDataFrameFrom()
Copy link
Collaborator

Choose a reason for hiding this comment

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

To and to?, again, could they be a CONSTANTS?

@@ -269,6 +270,10 @@ fun <T> KotlinTypeFacade.interpret(
}
}

fun interpretationFrameworkError(message: String): Nothing = throw InterpretationFrameworkError(message)
Copy link
Collaborator

Choose a reason for hiding this comment

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

the name looks like object name, not a function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Can't argue, but i was inspired by "error" function from standard library

}
val expectedArgsMap = processor.expectedArguments
.filterNot { it.name.startsWith("typeArg") }
.associateBy { it.name }.toSortedMap().minus(additionalArguments.keys)

if (expectedArgsMap.keys - defaultArguments != actualArgsMap.keys - defaultArguments) {
val unexpectedArguments = expectedArgsMap.keys - defaultArguments != actualArgsMap.keys - defaultArguments
Copy link
Collaborator

Choose a reason for hiding this comment

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

very interesting algebra of arguments (great to explain somehow this kind of logic)

Copy link
Collaborator Author

@koperagen koperagen Jul 16, 2024

Choose a reason for hiding this comment

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

This check is needed to simplify debug if someone writes an interpreter for fun a(myArgument: String) but misspells myArgument as myArg123123ument. Expected argument (by interpreter) is myArg123123ument, actual myArgument.
Easy to check.
But with default value:

fun a(myArgument: String, myArgument1: String = "defaultValue")
a("abc")

actualArg = myArgument, expectedArg = myArg123123ument, myArgument1.
We know that for myArgument1 default value is provided, so we exclude such arguments from comparison: it's not a mistake.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But i can't say that i like the idea of adding this as a comment though. It might not be obvious in PR and i'm ok with providing a better explanations here. But in IDEA, won't you agree that code is enough?

…rt them as compilation errors. Add special constructor for errors that shouldn't be caught
Interpreters need an ability to pass arguments down to DSL, so introduce new "dsl" factory function
@koperagen koperagen force-pushed the compiler-plugin-dev branch from c5c02b9 to 642a2ee Compare July 16, 2024 17:56
@koperagen koperagen merged commit ddb9fac into master Jul 17, 2024
4 of 5 checks passed
@Jolanrensen Jolanrensen added the Compiler plugin Anything related to the DataFrame Compiler Plugin label Aug 8, 2024
@koperagen koperagen deleted the compiler-plugin-dev 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.

3 participants