dejankrak-db commented on code in PR #48795:
URL: https://github.com/apache/spark/pull/48795#discussion_r1833121469
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala:
##########
@@ -134,3 +139,70 @@ object ParserUtils extends SparkParserUtils {
sb.toString()
}
}
+
+object LabelUtils {
+ private val seenLabels: mutable.Set[String] = mutable.Set.empty
+
+ def init(): Unit = {
+ seenLabels.clear()
+ }
+
+ private def checkLabels(
+ beginLabelCtx: Option[BeginLabelContext],
+ endLabelCtx: Option[EndLabelContext]) : Unit = {
+ (beginLabelCtx, endLabelCtx) match {
+ case (Some(bl: BeginLabelContext), Some(el: EndLabelContext))
+ if bl.multipartIdentifier().getText.nonEmpty &&
+ bl.multipartIdentifier().getText.toLowerCase(Locale.ROOT) !=
+ el.multipartIdentifier().getText.toLowerCase(Locale.ROOT) =>
+ withOrigin(bl) {
+ seenLabels.clear()
+ throw SqlScriptingErrors.labelsMismatch(
+ CurrentOrigin.get,
+ bl.multipartIdentifier().getText,
+ el.multipartIdentifier().getText)
+ }
+ case (None, Some(el: EndLabelContext)) =>
Review Comment:
Do you also need to explicitly handle case (Some(bl: BeginLabelContext),
None), or this can fall into the default case _ below?
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/ParserUtils.scala:
##########
@@ -134,3 +139,70 @@ object ParserUtils extends SparkParserUtils {
sb.toString()
}
}
+
+object LabelUtils {
+ private val seenLabels: mutable.Set[String] = mutable.Set.empty
+
+ def init(): Unit = {
+ seenLabels.clear()
+ }
+
+ private def checkLabels(
+ beginLabelCtx: Option[BeginLabelContext],
+ endLabelCtx: Option[EndLabelContext]) : Unit = {
+ (beginLabelCtx, endLabelCtx) match {
+ case (Some(bl: BeginLabelContext), Some(el: EndLabelContext))
+ if bl.multipartIdentifier().getText.nonEmpty &&
Review Comment:
If begin label is empty, will the check always pass? Is this intended?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]