cloud-fan commented on code in PR #36154:
URL: https://github.com/apache/spark/pull/36154#discussion_r849109006


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ToNumberParser.scala:
##########
@@ -49,33 +49,58 @@ object ToNumberParser {
   final val WRAPPING_ANGLE_BRACKETS_TO_NEGATIVE_NUMBER_END = 'R'
 
   // This class represents one or more characters that we expect to be present 
in the input string
-  // based on the format string.
-  abstract class InputToken()
+  // based on the format string. The toString method returns a representation 
of each token suitable
+  // for use in error messages.
+  abstract class InputToken() {
+    def toString: String
+  }
   // Represents some number of digits (0-9).
   abstract class Digits extends InputToken
   // Represents exactly 'num' digits (0-9).
-  case class ExactlyAsManyDigits(num: Int) extends Digits
+  case class ExactlyAsManyDigits(num: Int) extends Digits {
+    override def toString: String = "digit sequence"
+  }
   // Represents at most 'num' digits (0-9).
-  case class AtMostAsManyDigits(num: Int) extends Digits
+  case class AtMostAsManyDigits(num: Int) extends Digits {
+    override def toString: String = "digit sequence"
+  }
   // Represents one decimal point (.).
-  case class DecimalPoint() extends InputToken
+  case class DecimalPoint() extends InputToken {
+    override def toString: String = ". or D"
+  }
   // Represents one thousands separator (,).
-  case class ThousandsSeparator() extends InputToken
+  case class ThousandsSeparator() extends InputToken {
+    override def toString: String = ", or G"
+  }
   // Represents one or more groups of Digits (0-9) with ThousandsSeparators 
(,) between each group.
   // The 'tokens' are the Digits and ThousandsSeparators in order; the 
'digits' are just the Digits.
-  case class DigitGroups(tokens: Seq[InputToken], digits: Seq[Digits]) extends 
InputToken
+  case class DigitGroups(tokens: Seq[InputToken], digits: Seq[Digits]) extends 
InputToken {
+    override def toString: String = "digit sequence"
+  }
   // Represents one dollar sign ($).
-  case class DollarSign() extends InputToken
+  case class DollarSign() extends InputToken {
+    override def toString: String = "$"
+  }
   // Represents one optional plus sign (+) or minus sign (-).
-  case class OptionalPlusOrMinusSign() extends InputToken
+  case class OptionalPlusOrMinusSign() extends InputToken {
+    override def toString: String = "S"
+  }
   // Represents one optional minus sign (-).
-  case class OptionalMinusSign() extends InputToken
+  case class OptionalMinusSign() extends InputToken {
+    override def toString: String = "MI"
+  }
   // Represents one opening angle bracket (<).
-  case class OpeningAngleBracket() extends InputToken
+  case class OpeningAngleBracket() extends InputToken {
+    override def toString: String = "PR"
+  }
   // Represents one closing angle bracket (>).
-  case class ClosingAngleBracket() extends InputToken
+  case class ClosingAngleBracket() extends InputToken {
+    override def toString: String = "PR"
+  }
   // Represents any unrecognized character other than the above.
-  case class InvalidUnrecognizedCharacter(char: Char) extends InputToken
+  case class InvalidUnrecognizedCharacter(char: Char) extends InputToken {
+    override def toString: String = s"character $char"

Review Comment:
   ```suggestion
       override def toString: String = s"character '$char'"
   ```



-- 
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]

Reply via email to