-
Notifications
You must be signed in to change notification settings - Fork 234
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
Implement Presto SQLGlot Optimizers #1300
Implement Presto SQLGlot Optimizers #1300
Conversation
querybook/server/lib/query_analysis/validation/validators/presto_optimizing_validator.py
Outdated
Show resolved
Hide resolved
querybook/server/lib/query_analysis/validation/validators/presto_optimizing_validator.py
Outdated
Show resolved
Hide resolved
return Trino.Tokenizer().tokenize(query) | ||
|
||
|
||
class BaseSQLGlotValidator(metaclass=ABCMeta): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will this base class only be used for the presto optimizing validators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now it's only used for Presto, but good point. I moved the BaseSQLGlotValidator
to a separate file so it can be used for other custom implementations
end_line: number | null; | ||
end_ch: number | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where are end_line
and end_ch
used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They'll be used in the upcoming UI PR (since we'll need start and end coordinates of text that needs to be changed)
* Implement Presto SQLGlot Optimizers (#1300) Create a PrestoOptimizingValidator that extends the PrestoExplainValidator to run validators that provide suggestions to rewrite & optimize the query the query * Implement UI for query optimization suggestions (#1302) Create a new tooltip for users to accept query optimization suggestions * Update querybook version, fix PrestoOptimizingValidator (#1304) * Fix minor UI suggestions (#1305)
* Implement Presto SQLGlot Optimizers (pinterest#1300) Create a PrestoOptimizingValidator that extends the PrestoExplainValidator to run validators that provide suggestions to rewrite & optimize the query the query * Implement UI for query optimization suggestions (pinterest#1302) Create a new tooltip for users to accept query optimization suggestions * Update querybook version, fix PrestoOptimizingValidator (pinterest#1304) * Fix minor UI suggestions (pinterest#1305)
Create a
PrestoOptimizingValidator
that extends thePrestoExplainValidator
to run validators that provide suggestions to rewrite & optimize the query the queryNew suggestions being made to make query run more quickly:
APPROX_DISTINCT(x)
instead ofCOUNT(DISTINCT x)
LIKE
clauses to useREGEXP_LIKE
UNION ALL
instead ofUNION
Suggestions are made by tokenizing query using
sqlglot
library and searching for matching patternsUpdate query/validation endpoint's return type
QueryValidationResult
to allow for a suggestion type (specifies start coordinate & end coordinate that is changed, and the suggestion text)Updated logic in Implement developer assistance query rewriting #1298 to return start/end coordinates of text to change, and a suggestion string