-
Notifications
You must be signed in to change notification settings - Fork 62
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
identifier normalization #1519
identifier normalization #1519
Conversation
Conformance comparison report-Cross Engine
Number failing in both: 180 Number passing in legacy engine but fail in eval engine: 255 Number failing in legacy engine but pass in eval engine: 261 Conformance comparison report-Cross Commit-LEGACY
Number failing in both: 441 Number passing in Base (ee6c814) but now fail: 0 Number failing in Base (ee6c814) but now pass: 0 Conformance comparison report-Cross Commit-EVAL
Number failing in both: 435 Number passing in Base (ee6c814) but now fail: 1 Number failing in Base (ee6c814) but now pass: 1 Click here to see
Click here to see
|
internal class NormalizeIdentifier( | ||
caseNormalization: CaseNormalization? | ||
) : AstPass { |
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.
- Merge this with IdentifierManager
- Use
init
to pick the normalization function ie(string) -> string
For example,
internal class NormalizeIdentifier(
mode: CaseNormalization,
) {
val normalize: (String) -> String
init {
normalize = when (mode) {
UPPERCASE -> Strings.uppercase
LOWERCASE -> Strings.lowercase
EXACTCASE -> { it }
}
}
}
Something like that so we aren't null checking and swithcing on mode every time.
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.
I guess this suggestion is based off the assumption that we also case preserve (after normalization), which is indeed how this PR is implemented.
But my thinking is to keep those two separate layer of indirection until at least the RFC is in draft.
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.
nit, but please keep the same package name "normalize" rather than changing it. I'm ok with moving this to planner, in fact, I think that's a great idea!
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.
Please remove IdentifierManager per my previous comments. The identifier normalization pass should hold/take an enum for the normalization type — that is all. There is no need for the identifier manager.
import org.partiql.ast.identifierSymbol | ||
|
||
// The identifier manager class takes in two parameters, | ||
// in case we want to decouple case preservation and case normalization behavior in the future. |
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.
We have explicitly decided NOT to decouple these per our latest discussion. This is an internal class, so we can always change this later, but for now let's not create edge-cases that we've explicitly decided against.
Closing for now. |
Relevant Issues
Description
This PR adds a planner flag that determines the case normalization behavior.
Lvalue
andRvalue
by uppercasing the original text.Lvalue
andRvalue
by lowercasing the original text.Lvalue
andRvalue
by preserving the original text.Lvalue
by preserving the original text, no Rvalue normalization.To better separate
Lvalue
andRvalue
, this PR introduce a Binder Node in AST.The Identifier/Binder normalization happens at the planner package, as the first step for AST normalization.
AS
alias for from source.Other Information
Updated Unreleased Section in CHANGELOG: [YES/NO]
Any backward-incompatible changes? [YES/NO]
Any new external dependencies? [YES/NO]
Do your changes comply with the Contributing Guidelines
and Code Style Guidelines? [YES/NO]
Yes.
License Information
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.