This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 208c74d [KYUUBI #1105][FOLLOWUP] Minor improve
`ZorderBytesUtils.defaultValue`
208c74d is described below
commit 208c74d1978a2ef7873692ba0ca3235ee21f4649
Author: Fu Chen <[email protected]>
AuthorDate: Mon Sep 20 10:35:26 2021 +0800
[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 <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../org/apache/kyuubi/sql/zorder/Zorder.scala | 1 -
.../kyuubi/sql/zorder/ZorderBytesUtils.scala | 47 ++++++++++------------
2 files changed, 22 insertions(+), 26 deletions(-)
diff --git
a/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/Zorder.scala
b/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/Zorder.scala
index 16863ee..49661e0 100644
---
a/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/Zorder.scala
+++
b/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/Zorder.scala
@@ -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 = {
diff --git
a/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/ZorderBytesUtils.scala
b/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/ZorderBytesUtils.scala
index a64f458..b14d749 100644
---
a/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/ZorderBytesUtils.scala
+++
b/dev/kyuubi-extension-spark-3-1/src/main/scala/org/apache/kyuubi/sql/zorder/ZorderBytesUtils.scala
@@ -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)
}
}