-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
partiql-planner/src/main/kotlin/org/partiql/planner/internal/IdentifierManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.partiql.planner.internal | ||
|
||
import org.partiql.ast.Binder | ||
import org.partiql.ast.Identifier | ||
import org.partiql.ast.binder | ||
import org.partiql.ast.identifierSymbol | ||
|
||
internal class IdentifierManager( | ||
val casePreservation: Boolean, | ||
val rValue: RValue | ||
) { | ||
fun normalizeBinder(binder: Binder): Binder { | ||
return if (casePreservation) { | ||
binder(binder.symbol, Binder.CaseSensitivity.SENSITIVE) | ||
} | ||
// This is a conscious decision | ||
// Even though the case preservation is off, we still need a way to store the binder | ||
// To make this compatible with the current implementation, | ||
// the decision here is: we normalize by preserving case. | ||
else { | ||
binder(binder.symbol, Binder.CaseSensitivity.SENSITIVE) | ||
} | ||
} | ||
|
||
fun normalizeRvalue(id: Identifier.Symbol): Identifier.Symbol = | ||
when (rValue) { | ||
RValue.FOLDING_UP -> identifierSymbol(id.symbol.uppercase(), Identifier.CaseSensitivity.SENSITIVE) | ||
RValue.FOLDING_DOWN -> identifierSymbol(id.symbol.lowercase(), Identifier.CaseSensitivity.SENSITIVE) | ||
RValue.SENSITIVE -> identifierSymbol(id.symbol, Identifier.CaseSensitivity.SENSITIVE) | ||
RValue.INSENSITIVE -> identifierSymbol(id.symbol, Identifier.CaseSensitivity.INSENSITIVE) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters