[KYUUBI #1105][FOLLOWUP] Minor improve ZorderBytesUtils.defaultValue
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html 2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'. 3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'. --> ### _Why are the changes needed?_ <!-- Please clarify why the changes are needed. For instance, 1. If you add a feature, you can talk about the use case of it. 2. If you fix a bug, you can clarify why it is a bug. --> fix [comment](https://github.com/apache/incubator-kyuubi/pull/1109#discussion_r711007709) ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1126 from cfmcgrady/zorder. Closes #1105 48e4d73a [Fu Chen] review a58c5e52 [Fu Chen] minor improve ZorderBytesUtils.defaultValue Authored-by: Fu Chen <cfmcgrady@gmail.com> Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
parent
cc3ca56ab2
commit
208c74d197
@ -46,7 +46,6 @@ case class Zorder(children: Seq[Expression]) extends Expression {
|
||||
private lazy val defaultNullValues: Array[Array[Byte]] =
|
||||
children.map(_.dataType)
|
||||
.map(ZorderBytesUtils.defaultValue)
|
||||
.map(ZorderBytesUtils.toByte)
|
||||
.toArray
|
||||
|
||||
override def eval(input: InternalRow): Any = {
|
||||
|
||||
@ -171,30 +171,27 @@ object ZorderBytesUtils {
|
||||
result
|
||||
}
|
||||
|
||||
def defaultValue(dataType: DataType): Any = dataType match {
|
||||
case BooleanType =>
|
||||
false
|
||||
case ByteType =>
|
||||
Byte.MaxValue
|
||||
case ShortType =>
|
||||
Short.MaxValue
|
||||
case IntegerType =>
|
||||
Int.MaxValue
|
||||
case LongType =>
|
||||
Long.MaxValue
|
||||
case FloatType =>
|
||||
Float.MaxValue
|
||||
case DoubleType =>
|
||||
Double.MaxValue
|
||||
case StringType =>
|
||||
UTF8String.fromBytes(new Array[Byte](0))
|
||||
case TimestampType =>
|
||||
Long.MaxValue
|
||||
case DateType =>
|
||||
Int.MaxValue
|
||||
case _: DecimalType =>
|
||||
Long.MaxValue
|
||||
case other: Any =>
|
||||
throw new KyuubiSQLExtensionException(s"Unsupported z-order type: ${other.catalogString}")
|
||||
def defaultValue(dataType: DataType): Array[Byte] = {
|
||||
val v = dataType match {
|
||||
case BooleanType =>
|
||||
false
|
||||
case ByteType =>
|
||||
Byte.MaxValue
|
||||
case ShortType =>
|
||||
Short.MaxValue
|
||||
case IntegerType | DateType =>
|
||||
Int.MaxValue
|
||||
case LongType | TimestampType | _: DecimalType =>
|
||||
Long.MaxValue
|
||||
case FloatType =>
|
||||
Float.MaxValue
|
||||
case DoubleType =>
|
||||
Double.MaxValue
|
||||
case StringType =>
|
||||
UTF8String.fromBytes(new Array[Byte](0))
|
||||
case other: Any =>
|
||||
throw new KyuubiSQLExtensionException(s"Unsupported z-order type: ${other.catalogString}")
|
||||
}
|
||||
toByte(v)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user