-
Notifications
You must be signed in to change notification settings - Fork 29k
[WIP][SPARK-54652] Complete conversion of IDENTIFIER() #53407
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
Open
aleksandr-chernousov-db
wants to merge
6
commits into
apache:master
Choose a base branch
from
aleksandr-chernousov-db:SPARK-54652
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,493
−49
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9d42d3a
Fix usage of identifiers
d5f8475
add tests
6433504
Update tests
72db2e8
Return getText for identifiers used as placeholders for keywords
aleksandr-chernousov-db 3d6ad1c
fix fmt
aleksandr-chernousov-db cc82512
tests for keywords
aleksandr-chernousov-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -1235,7 +1235,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| if (pVal.DEFAULT != null) { | ||
| throw QueryParsingErrors.defaultColumnReferencesNotAllowedInPartitionSpec(ctx) | ||
| } | ||
| val name = pVal.identifier.getText | ||
| val name = getIdentifierText(pVal.identifier) | ||
| val value = Option(pVal.constant).map(v => { | ||
| visitStringConstant(v, legacyNullAsString, keepPartitionSpecAsString) | ||
| }) | ||
|
|
@@ -1958,11 +1958,11 @@ class AstBuilder extends DataTypeAstBuilder | |
| .flatMap(_.namedExpression.asScala) | ||
| .map(typedVisit[Expression]) | ||
| val pivotColumn = if (ctx.pivotColumn.identifiers.size == 1) { | ||
| UnresolvedAttribute.quoted(ctx.pivotColumn.errorCapturingIdentifier.getText) | ||
| UnresolvedAttribute.quoted(getIdentifierText(ctx.pivotColumn.errorCapturingIdentifier)) | ||
| } else { | ||
| CreateStruct( | ||
| ctx.pivotColumn.identifiers.asScala.map( | ||
| identifier => UnresolvedAttribute.quoted(identifier.getText)).toSeq) | ||
| identifier => UnresolvedAttribute.quoted(getIdentifierText(identifier))).toSeq) | ||
| } | ||
| val pivotValues = ctx.pivotValues.asScala.map(visitPivotValue) | ||
| Pivot(None, pivotColumn, pivotValues.toSeq, aggregates, query) | ||
|
|
@@ -1974,7 +1974,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| override def visitPivotValue(ctx: PivotValueContext): Expression = withOrigin(ctx) { | ||
| val e = expression(ctx.expression) | ||
| if (ctx.errorCapturingIdentifier != null) { | ||
| Alias(e, ctx.errorCapturingIdentifier.getText)() | ||
| Alias(e, getIdentifierText(ctx.errorCapturingIdentifier))() | ||
| } else { | ||
| e | ||
| } | ||
|
|
@@ -2039,7 +2039,7 @@ class AstBuilder extends DataTypeAstBuilder | |
|
|
||
| // alias unpivot result | ||
| if (ctx.errorCapturingIdentifier() != null) { | ||
| val alias = ctx.errorCapturingIdentifier().getText | ||
| val alias = getIdentifierText(ctx.errorCapturingIdentifier()) | ||
| SubqueryAlias(alias, filtered) | ||
| } else { | ||
| filtered | ||
|
|
@@ -2541,7 +2541,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| */ | ||
| private def mayApplyAliasPlan(tableAlias: TableAliasContext, plan: LogicalPlan): LogicalPlan = { | ||
| if (tableAlias.strictIdentifier != null) { | ||
| val alias = tableAlias.strictIdentifier.getText | ||
| val alias = getIdentifierText(tableAlias.strictIdentifier) | ||
| if (tableAlias.identifierList != null) { | ||
| val columnNames = visitIdentifierList(tableAlias.identifierList) | ||
| SubqueryAlias(alias, UnresolvedSubqueryColumnAliases(columnNames, plan)) | ||
|
|
@@ -3229,7 +3229,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| */ | ||
| override def visitLambda(ctx: LambdaContext): Expression = withOrigin(ctx) { | ||
| val arguments = ctx.identifier().asScala.map { name => | ||
| UnresolvedNamedLambdaVariable(UnresolvedAttribute.quoted(name.getText).nameParts) | ||
| UnresolvedNamedLambdaVariable(UnresolvedAttribute.quoted(getIdentifierText(name)).nameParts) | ||
| } | ||
| val function = expression(ctx.expression).transformUp { | ||
| case a: UnresolvedAttribute => UnresolvedNamedLambdaVariable(a.nameParts) | ||
|
|
@@ -4261,7 +4261,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| if (!SQLConf.get.objectLevelCollationsEnabled) { | ||
| throw QueryCompilationErrors.objectLevelCollationsNotEnabledError() | ||
| } | ||
| val collationName = ctx.identifier.getText | ||
| val collationName = getIdentifierText(ctx.identifier) | ||
| CollationFactory.fetchCollation(collationName).collationName | ||
| } | ||
|
|
||
|
|
@@ -4500,7 +4500,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| def getFieldReference( | ||
| ctx: ApplyTransformContext, | ||
| arg: V2Expression): FieldReference = { | ||
| lazy val name: String = ctx.identifier.getText | ||
| lazy val name: String = getIdentifierText(ctx.identifier) | ||
| arg match { | ||
| case ref: FieldReference => | ||
| ref | ||
|
|
@@ -4512,7 +4512,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| def getSingleFieldReference( | ||
| ctx: ApplyTransformContext, | ||
| arguments: Seq[V2Expression]): FieldReference = { | ||
| lazy val name: String = ctx.identifier.getText | ||
| lazy val name: String = getIdentifierText(ctx.identifier) | ||
| if (arguments.size > 1) { | ||
| throw QueryParsingErrors.wrongNumberArgumentsForTransformError(name, arguments.size, ctx) | ||
| } else if (arguments.isEmpty) { | ||
|
|
@@ -4529,7 +4529,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| case applyCtx: ApplyTransformContext => | ||
| val arguments = applyCtx.argument.asScala.map(visitTransformArgument).toSeq | ||
|
|
||
| applyCtx.identifier.getText match { | ||
| getIdentifierText(applyCtx.identifier) match { | ||
| case "bucket" => | ||
| val numBuckets: Int = arguments.head match { | ||
| case LiteralValue(shortValue, ShortType) => | ||
|
|
@@ -4797,7 +4797,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| string(visitStringLit(c.outFmt))))) | ||
| // Expected format: SEQUENCEFILE | TEXTFILE | RCFILE | ORC | PARQUET | AVRO | ||
| case (c: GenericFileFormatContext, null) => | ||
| SerdeInfo(storedAs = Some(c.identifier.getText)) | ||
| SerdeInfo(storedAs = Some(getIdentifierText(c.identifier))) | ||
| case (null, storageHandler) => | ||
| invalidStatement("STORED BY", ctx) | ||
| case _ => | ||
|
|
@@ -4887,15 +4887,15 @@ class AstBuilder extends DataTypeAstBuilder | |
| (rowFormatCtx, createFileFormatCtx.fileFormat) match { | ||
| case (_, ffTable: TableFileFormatContext) => // OK | ||
| case (rfSerde: RowFormatSerdeContext, ffGeneric: GenericFileFormatContext) => | ||
| ffGeneric.identifier.getText.toLowerCase(Locale.ROOT) match { | ||
| getIdentifierText(ffGeneric.identifier).toLowerCase(Locale.ROOT) match { | ||
aleksandr-chernousov-db marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| case ("sequencefile" | "textfile" | "rcfile") => // OK | ||
| case fmt => | ||
| operationNotAllowed( | ||
| s"ROW FORMAT SERDE is incompatible with format '$fmt', which also specifies a serde", | ||
| parentCtx) | ||
| } | ||
| case (rfDelimited: RowFormatDelimitedContext, ffGeneric: GenericFileFormatContext) => | ||
| ffGeneric.identifier.getText.toLowerCase(Locale.ROOT) match { | ||
| getIdentifierText(ffGeneric.identifier).toLowerCase(Locale.ROOT) match { | ||
|
||
| case "textfile" => // OK | ||
| case fmt => operationNotAllowed( | ||
| s"ROW FORMAT DELIMITED is only compatible with 'textfile', not '$fmt'", parentCtx) | ||
|
|
@@ -5838,7 +5838,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| } | ||
| } | ||
| if (ctx.identifier != null && | ||
| ctx.identifier.getText.toLowerCase(Locale.ROOT) != "noscan") { | ||
| getIdentifierText(ctx.identifier).toLowerCase(Locale.ROOT) != "noscan") { | ||
aleksandr-chernousov-db marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| throw QueryParsingErrors.computeStatisticsNotExpectedError(ctx.identifier()) | ||
| } | ||
|
|
||
|
|
@@ -5879,7 +5879,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| */ | ||
| override def visitAnalyzeTables(ctx: AnalyzeTablesContext): LogicalPlan = withOrigin(ctx) { | ||
| if (ctx.identifier != null && | ||
| ctx.identifier.getText.toLowerCase(Locale.ROOT) != "noscan") { | ||
| getIdentifierText(ctx.identifier).toLowerCase(Locale.ROOT) != "noscan") { | ||
aleksandr-chernousov-db marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| throw QueryParsingErrors.computeStatisticsNotExpectedError(ctx.identifier()) | ||
| } | ||
| val ns = if (ctx.identifierReference() != null) { | ||
|
|
@@ -6433,7 +6433,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| * }}} | ||
| */ | ||
| override def visitDropIndex(ctx: DropIndexContext): LogicalPlan = withOrigin(ctx) { | ||
| val indexName = ctx.identifier.getText | ||
| val indexName = getIdentifierText(ctx.identifier) | ||
| DropIndex( | ||
| createUnresolvedTable(ctx.identifierReference, "DROP INDEX"), | ||
| indexName, | ||
|
|
@@ -6655,7 +6655,7 @@ class AstBuilder extends DataTypeAstBuilder | |
| target = None, excepts = ids.map(s => Seq(s)), replacements = None)) | ||
| Project(projectList, left) | ||
| }.getOrElse(Option(ctx.AS).map { _ => | ||
| SubqueryAlias(ctx.errorCapturingIdentifier().getText, left) | ||
| SubqueryAlias(getIdentifierText(ctx.errorCapturingIdentifier()), left) | ||
| }.getOrElse(Option(ctx.whereClause).map { c => | ||
| if (ctx.windowClause() != null) { | ||
| throw QueryParsingErrors.windowClauseInPipeOperatorWhereClauseNotAllowedError(ctx) | ||
|
|
||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.