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

Evaluate how SQL interacts with Painless #50383

Closed
stu-elastic opened this issue Dec 19, 2019 · 4 comments
Closed

Evaluate how SQL interacts with Painless #50383

stu-elastic opened this issue Dec 19, 2019 · 4 comments
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement Team:Core/Infra Meta label for core/infra team

Comments

@stu-elastic
Copy link
Contributor

stu-elastic commented Dec 19, 2019

In order to allow SQL to write to the Painless internal representation via an IR builder, we need to look at how parsed SQL interacts with Painless to get good API ideas.

Base class is InternalSqlScriptUtils registered in sql_whitelist.txt.

We can check QueryTranslatorTests eg testChronoFieldBasedDateTimeFunctionsWithMathIntervalAndGroupBy to get a sense of the script generation which takes place through the ScriptWeaver interface.

Every scalar function implements it's own script. For something like SELECT f1(f2(f3(f4…..)each function generates its portion of the ScriptTemplate which is passed to the next one in the chain resulting the the final script.

The parser lives in org.elasticsearch.xpack.sql.parser, SqlParser, ExpressionBuilder. SqlBase.g4 is the antlr4 grammar.

cc: @jdconrad @matriv
Related: #49869

@stu-elastic stu-elastic added >enhancement :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache labels Dec 19, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

@stu-elastic
Copy link
Contributor Author

SQL goes through an Analysis phase, verification phase, optimization phase, query translation phase. We'd wanna hook into the query translation phase. Instead of painless scripts being the output of that phase, we'd hook directly into an IR builder.

@stu-elastic
Copy link
Contributor Author

Related: #49672

@rjernst rjernst added the Team:Core/Infra Meta label for core/infra team label May 4, 2020
@rjernst rjernst added the needs:triage Requires assignment of a team area label label Dec 3, 2020
@stu-elastic
Copy link
Contributor Author

This is being addressed with the compiler rework.

@stu-elastic stu-elastic removed the needs:triage Requires assignment of a team area label label Dec 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

3 participants