-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26071][SQL] disallow map as map key #23045
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -521,13 +521,18 @@ case class MapEntries(child: Expression) extends UnaryExpression with ExpectsInp | |
| case class MapConcat(children: Seq[Expression]) extends ComplexTypeMergingExpression { | ||
|
|
||
| override def checkInputDataTypes(): TypeCheckResult = { | ||
| var funcName = s"function $prettyName" | ||
| val funcName = s"function $prettyName" | ||
| if (children.exists(!_.dataType.isInstanceOf[MapType])) { | ||
| TypeCheckResult.TypeCheckFailure( | ||
| s"input to $funcName should all be of type map, but it's " + | ||
| children.map(_.dataType.catalogString).mkString("[", ", ", "]")) | ||
| } else { | ||
| TypeUtils.checkForSameTypeInputExpr(children.map(_.dataType), funcName) | ||
| val sameTypeCheck = TypeUtils.checkForSameTypeInputExpr(children.map(_.dataType), funcName) | ||
| if (sameTypeCheck.isFailure) { | ||
| sameTypeCheck | ||
| } else { | ||
| TypeUtils.checkForMapKeyType(dataType.keyType) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we need this. The children already should not have map type keys?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see https://github.com/apache/spark/pull/23045/files#diff-3f19ec3d15dcd8cd42bb25dde1c5c1a9R20 . The child may be read from parquet files, so map of map is still possible.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, I see. thanks! |
||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -740,7 +745,8 @@ case class MapFromEntries(child: Expression) extends UnaryExpression { | |
| @transient override lazy val dataType: MapType = dataTypeDetails.get._1 | ||
|
|
||
| override def checkInputDataTypes(): TypeCheckResult = dataTypeDetails match { | ||
| case Some(_) => TypeCheckResult.TypeCheckSuccess | ||
| case Some((mapType, _, _)) => | ||
| TypeUtils.checkForMapKeyType(mapType.keyType) | ||
| case None => TypeCheckResult.TypeCheckFailure(s"'${child.sql}' is of " + | ||
| s"${child.dataType.catalogString} type. $prettyName accepts only arrays of pair structs.") | ||
| } | ||
|
|
||
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 think should we also add this note?