class ToNumberParser extends Serializable
This class represents a parser to implement the to_number or try_to_number SQL functions.
It works by consuming an input string and a format string. This class accepts the format string as a field, and proceeds to iterate through the format string to generate a sequence of tokens (or throw an exception if the format string is invalid). Then when the function is called with an input string, this class steps through the sequence of tokens and compares them against the input string, returning a Spark Decimal object if they match (or throwing an exception otherwise).
- Alphabetic
- By Inheritance
- ToNumberParser
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new ToNumberParser(numberFormat: String, errorOnFail: Boolean)
- numberFormat
the format string describing the expected inputs.
- errorOnFail
true if evaluation should throw an exception if the input string fails to match the format string. Otherwise, returns NULL instead.
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def checkInputDataTypes(): TypeCheckResult
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def format(input: Decimal): UTF8String
Converts a decimal value to a string based on the given number format.
Converts a decimal value to a string based on the given number format.
Iterates through the formatTokens obtained from processing the format string, while also inspecting the input decimal value.
- input
the decimal value that needs to be converted
- returns
the result String value obtained from string formatting
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def parse(input: UTF8String): Decimal
Convert string to numeric based on the given number format.
Convert string to numeric based on the given number format.
Iterates through the formatTokens obtained from processing the format string, while also keeping a parallel index into the input string. Throws an exception if the latter does not contain expected characters at any point.
- input
the string that needs to converted
- returns
the result Decimal value obtained from string parsing
- def parsedDecimalType: DecimalType
The result type of this parsing is a Decimal value with the appropriate precision and scale.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()