You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/04/27 09:17:59 UTC
[GitHub] [spark] yaooqinn opened a new pull request, #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
yaooqinn opened a new pull request, #36373:
URL: https://github.com/apache/spark/pull/36373
<!--
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://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
The PR is mainly refactoring, aiming to support TimestampNTZ/LTZ at the same time in the future for the thrift server.
As we all know, in spark, we hive dependencies, which can be classified into two types:
- as a client, for accessing hive metastore/storage, etc, which is now v2.3.9, better to stay in a stable low version to be supported by higher hive metastore servers with backward compatibility
- as a server, for being accessed by Hive JDBC/Thrift client, e.g. beeline, which is now v3.1.2, better to have a higher version to support more clients
The problem here is that we now convert spark results to `org.apache.hadoop.hive.serde2.thrift.Type` first and then to `org.apache.hive.service.rpc.thrift.TTypeId`. the former does not have 2 timestamp types, namely, doesn't have `TIMESTAMPLOCALTZ_TYPE`.
To avoid this, we take a shortcut to map spark results to thrift schema and rowset directly.
Besides, it also can avoid some unnecessary memory copies from type to type.
Most functionalities have been verified in [apache/kyuubi](https://github.com/apache/incubator-kyuubi) for several years.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
for supporting more spark datatypes through hive jdbc
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
If benchmark tests were added, please run the benchmarks in GitHub Actions for the consistent environment, and the instructions could accord to: https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
-->
existing ut shall be enough
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly [spark]
Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on PR #36373:
URL: https://github.com/apache/spark/pull/36373#issuecomment-2186573113
From HIVE-12049
```diff
else {
+ if (tRowSet.getColumns() != null) {
+ for (TColumn tvalue : tRowSet.getColumns()) {
+ columns.add(new ColumnBuffer(tvalue));
+ }
+ }
}
It looks like the client-side code needs to check `tRowSet.getColumns()` not being null when reconstructed the rowset?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly [spark]
Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on PR #36373:
URL: https://github.com/apache/spark/pull/36373#issuecomment-2208448456
Can we fix it through service side. Because it is difficult to update the client version.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r860925448
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/RowSetUtils.scala:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.nio.ByteBuffer
+
+import scala.collection.JavaConverters._
+import scala.language.implicitConversions
+
+import org.apache.hive.service.rpc.thrift._
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.execution.HiveResult.{toHiveString, TimeFormatters}
+import org.apache.spark.sql.types.{BinaryType, BooleanType, ByteType, DataType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType}
+
+object RowSetUtils {
+
+ implicit def bitSetToBuffer(bitSet: java.util.BitSet): ByteBuffer = {
+ ByteBuffer.wrap(bitSet.toByteArray)
+ }
+
+ def toTRowSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ protocolVersion: TProtocolVersion,
+ timeFormatters: TimeFormatters): TRowSet = {
+ if (protocolVersion.getValue < TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+ toRowBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ } else {
+ toColumnBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ }
+ }
+
+ private def toRowBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ var i = 0
+ val rowSize = rows.length
+ val tRows = new java.util.ArrayList[TRow](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ val tRow = new TRow()
+ var j = 0
+ val columnSize = row.length
+ while (j < columnSize) {
+ val columnValue = toTColumnValue(j, row, schema(j), timeFormatters)
+ tRow.addToColVals(columnValue)
+ j += 1
+ }
+ i += 1
+ tRows.add(tRow)
+ }
+ new TRowSet(startRowOffSet, tRows)
+ }
+
+ private def toColumnBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ val rowSize = rows.length
+ val tRowSet = new TRowSet(startRowOffSet, new java.util.ArrayList[TRow](rowSize))
+ var i = 0
+ val columnSize = schema.length
+ while (i < columnSize) {
+ val tColumn = toTColumn(rows, i, schema(i), timeFormatters)
+ tRowSet.addToColumns(tColumn)
+ i += 1
+ }
+ tRowSet
+ }
+
+ private def toTColumn(
+ rows: Seq[Row], ordinal: Int, typ: DataType, timeFormatters: TimeFormatters): TColumn = {
+ val nulls = new java.util.BitSet()
+ typ match {
+ case BooleanType =>
+ val values = getOrSetAsNull[java.lang.Boolean](rows, ordinal, nulls, true)
+ TColumn.boolVal(new TBoolColumn(values, nulls))
+
+ case ByteType =>
+ val values = getOrSetAsNull[java.lang.Byte](rows, ordinal, nulls, 0.toByte)
+ TColumn.byteVal(new TByteColumn(values, nulls))
+
+ case ShortType =>
+ val values = getOrSetAsNull[java.lang.Short](rows, ordinal, nulls, 0.toShort)
+ TColumn.i16Val(new TI16Column(values, nulls))
+
+ case IntegerType =>
+ val values = getOrSetAsNull[java.lang.Integer](rows, ordinal, nulls, 0)
+ TColumn.i32Val(new TI32Column(values, nulls))
+
+ case LongType =>
+ val values = getOrSetAsNull[java.lang.Long](rows, ordinal, nulls, 0L)
+ TColumn.i64Val(new TI64Column(values, nulls))
+
+ case FloatType =>
+ val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case DoubleType =>
+ val values = getOrSetAsNull[java.lang.Double](rows, ordinal, nulls, 0.toDouble)
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case StringType =>
+ val values = getOrSetAsNull[java.lang.String](rows, ordinal, nulls, "")
+ TColumn.stringVal(new TStringColumn(values, nulls))
+
+ case BinaryType =>
+ val values = getOrSetAsNull[Array[Byte]](rows, ordinal, nulls, Array.empty[Byte])
+ .asScala
+ .map(ByteBuffer.wrap)
+ .asJava
+ TColumn.binaryVal(new TBinaryColumn(values, nulls))
+
+ case _ =>
+ var i = 0
+ val rowSize = rows.length
+ val values = new java.util.ArrayList[String](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ nulls.set(i, row.isNullAt(ordinal))
+ val value = if (row.isNullAt(ordinal)) {
+ ""
+ } else {
+ toHiveString((row.get(ordinal), typ), nested = true, timeFormatters)
+ }
+ values.add(value)
+ i += 1
+ }
+ TColumn.stringVal(new TStringColumn(values, nulls))
+ }
+ }
+
+ private def getOrSetAsNull[T](
+ rows: Seq[Row],
+ ordinal: Int,
+ nulls: java.util.BitSet,
+ defaultVal: T): java.util.List[T] = {
+ val size = rows.length
+ val ret = new java.util.ArrayList[T](size)
+ var idx = 0
+ while (idx < size) {
+ val row = rows(idx)
+ if (row.isNullAt(ordinal)) {
+ nulls.set(idx, true)
+ ret.add(idx, defaultVal)
+ } else {
+ ret.add(idx, row.getAs[T](ordinal))
+ }
+ idx += 1
+ }
+ ret
+ }
+
+ private def toTColumnValue(
+ ordinal: Int,
+ row: Row,
+ dataType: DataType,
+ timeFormatters: TimeFormatters): TColumnValue = {
+ dataType match {
+ case BooleanType =>
+ val boolValue = new TBoolValue
+ if (!row.isNullAt(ordinal)) boolValue.setValue(row.getBoolean(ordinal))
+ TColumnValue.boolVal(boolValue)
+
+ case ByteType =>
+ val byteValue = new TByteValue
+ if (!row.isNullAt(ordinal)) byteValue.setValue(row.getByte(ordinal))
+ TColumnValue.byteVal(byteValue)
+
+ case ShortType =>
+ val tI16Value = new TI16Value
+ if (!row.isNullAt(ordinal)) tI16Value.setValue(row.getShort(ordinal))
+ TColumnValue.i16Val(tI16Value)
+
+ case IntegerType =>
+ val tI32Value = new TI32Value
+ if (!row.isNullAt(ordinal)) tI32Value.setValue(row.getInt(ordinal))
+ TColumnValue.i32Val(tI32Value)
+
+ case LongType =>
+ val tI64Value = new TI64Value
+ if (!row.isNullAt(ordinal)) tI64Value.setValue(row.getLong(ordinal))
+ TColumnValue.i64Val(tI64Value)
+
+ case FloatType =>
+ val tDoubleValue = new TDoubleValue
+ if (!row.isNullAt(ordinal)) {
+ val doubleValue = java.lang.Double.valueOf(row.getFloat(ordinal).toString)
Review Comment:
Can we add a comment to explain it?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r860898562
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/RowSetUtils.scala:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.nio.ByteBuffer
+
+import scala.collection.JavaConverters._
+import scala.language.implicitConversions
+
+import org.apache.hive.service.rpc.thrift._
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.execution.HiveResult.{toHiveString, TimeFormatters}
+import org.apache.spark.sql.types.{BinaryType, BooleanType, ByteType, DataType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType}
+
+object RowSetUtils {
+
+ implicit def bitSetToBuffer(bitSet: java.util.BitSet): ByteBuffer = {
+ ByteBuffer.wrap(bitSet.toByteArray)
+ }
+
+ def toTRowSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ protocolVersion: TProtocolVersion,
+ timeFormatters: TimeFormatters): TRowSet = {
+ if (protocolVersion.getValue < TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+ toRowBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ } else {
+ toColumnBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ }
+ }
+
+ private def toRowBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ var i = 0
+ val rowSize = rows.length
+ val tRows = new java.util.ArrayList[TRow](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ val tRow = new TRow()
+ var j = 0
+ val columnSize = row.length
+ while (j < columnSize) {
+ val columnValue = toTColumnValue(j, row, schema(j), timeFormatters)
+ tRow.addToColVals(columnValue)
+ j += 1
+ }
+ i += 1
+ tRows.add(tRow)
+ }
+ new TRowSet(startRowOffSet, tRows)
+ }
+
+ private def toColumnBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ val rowSize = rows.length
+ val tRowSet = new TRowSet(startRowOffSet, new java.util.ArrayList[TRow](rowSize))
+ var i = 0
+ val columnSize = schema.length
+ while (i < columnSize) {
+ val tColumn = toTColumn(rows, i, schema(i), timeFormatters)
+ tRowSet.addToColumns(tColumn)
+ i += 1
+ }
+ tRowSet
+ }
+
+ private def toTColumn(
+ rows: Seq[Row], ordinal: Int, typ: DataType, timeFormatters: TimeFormatters): TColumn = {
+ val nulls = new java.util.BitSet()
+ typ match {
+ case BooleanType =>
+ val values = getOrSetAsNull[java.lang.Boolean](rows, ordinal, nulls, true)
+ TColumn.boolVal(new TBoolColumn(values, nulls))
+
+ case ByteType =>
+ val values = getOrSetAsNull[java.lang.Byte](rows, ordinal, nulls, 0.toByte)
+ TColumn.byteVal(new TByteColumn(values, nulls))
+
+ case ShortType =>
+ val values = getOrSetAsNull[java.lang.Short](rows, ordinal, nulls, 0.toShort)
+ TColumn.i16Val(new TI16Column(values, nulls))
+
+ case IntegerType =>
+ val values = getOrSetAsNull[java.lang.Integer](rows, ordinal, nulls, 0)
+ TColumn.i32Val(new TI32Column(values, nulls))
+
+ case LongType =>
+ val values = getOrSetAsNull[java.lang.Long](rows, ordinal, nulls, 0L)
+ TColumn.i64Val(new TI64Column(values, nulls))
+
+ case FloatType =>
+ val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case DoubleType =>
+ val values = getOrSetAsNull[java.lang.Double](rows, ordinal, nulls, 0.toDouble)
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case StringType =>
+ val values = getOrSetAsNull[java.lang.String](rows, ordinal, nulls, "")
+ TColumn.stringVal(new TStringColumn(values, nulls))
+
+ case BinaryType =>
+ val values = getOrSetAsNull[Array[Byte]](rows, ordinal, nulls, Array.empty[Byte])
+ .asScala
+ .map(ByteBuffer.wrap)
+ .asJava
+ TColumn.binaryVal(new TBinaryColumn(values, nulls))
+
+ case _ =>
+ var i = 0
+ val rowSize = rows.length
+ val values = new java.util.ArrayList[String](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ nulls.set(i, row.isNullAt(ordinal))
+ val value = if (row.isNullAt(ordinal)) {
+ ""
+ } else {
+ toHiveString((row.get(ordinal), typ), nested = true, timeFormatters)
+ }
+ values.add(value)
+ i += 1
+ }
+ TColumn.stringVal(new TStringColumn(values, nulls))
+ }
+ }
+
+ private def getOrSetAsNull[T](
+ rows: Seq[Row],
+ ordinal: Int,
+ nulls: java.util.BitSet,
+ defaultVal: T): java.util.List[T] = {
+ val size = rows.length
+ val ret = new java.util.ArrayList[T](size)
+ var idx = 0
+ while (idx < size) {
+ val row = rows(idx)
+ if (row.isNullAt(ordinal)) {
+ nulls.set(idx, true)
+ ret.add(idx, defaultVal)
+ } else {
+ ret.add(idx, row.getAs[T](ordinal))
+ }
+ idx += 1
+ }
+ ret
+ }
+
+ private def toTColumnValue(
+ ordinal: Int,
+ row: Row,
+ dataType: DataType,
+ timeFormatters: TimeFormatters): TColumnValue = {
+ dataType match {
+ case BooleanType =>
+ val boolValue = new TBoolValue
+ if (!row.isNullAt(ordinal)) boolValue.setValue(row.getBoolean(ordinal))
+ TColumnValue.boolVal(boolValue)
+
+ case ByteType =>
+ val byteValue = new TByteValue
+ if (!row.isNullAt(ordinal)) byteValue.setValue(row.getByte(ordinal))
+ TColumnValue.byteVal(byteValue)
+
+ case ShortType =>
+ val tI16Value = new TI16Value
+ if (!row.isNullAt(ordinal)) tI16Value.setValue(row.getShort(ordinal))
+ TColumnValue.i16Val(tI16Value)
+
+ case IntegerType =>
+ val tI32Value = new TI32Value
+ if (!row.isNullAt(ordinal)) tI32Value.setValue(row.getInt(ordinal))
+ TColumnValue.i32Val(tI32Value)
+
+ case LongType =>
+ val tI64Value = new TI64Value
+ if (!row.isNullAt(ordinal)) tI64Value.setValue(row.getLong(ordinal))
+ TColumnValue.i64Val(tI64Value)
+
+ case FloatType =>
+ val tDoubleValue = new TDoubleValue
+ if (!row.isNullAt(ordinal)) {
+ val doubleValue = java.lang.Double.valueOf(row.getFloat(ordinal).toString)
Review Comment:
is the `.toString` necessary?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r871502997
##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/session/HiveSession.java:
##########
@@ -182,11 +184,11 @@ OperationHandle getCrossReference(String primaryCatalog,
void closeOperation(OperationHandle opHandle) throws HiveSQLException;
- TableSchema getResultSetMetadata(OperationHandle opHandle)
+ TTableSchema getResultSetMetadata(OperationHandle opHandle)
throws HiveSQLException;
- RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation,
- long maxRows, FetchType fetchType) throws HiveSQLException;
+ TRowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation,
+ long maxRows, FetchType fetchType) throws HiveSQLException;
Review Comment:
```suggestion
long maxRows, FetchType fetchType) throws HiveSQLException;
```
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #36373:
URL: https://github.com/apache/spark/pull/36373#issuecomment-1125599377
thanks, merged to master
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r859583552
##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/CLIServiceClient.java:
##########
@@ -35,7 +36,7 @@ public SessionHandle openSession(String username, String password)
}
@Override
- public RowSet fetchResults(OperationHandle opHandle) throws HiveSQLException {
+ public TRowSet fetchResults(OperationHandle opHandle) throws HiveSQLException {
Review Comment:
CLIServiceClient and its child is used in our test only, changes here will not have impacts on real-world clients
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly [spark]
Posted by "wangyum (via GitHub)" <gi...@apache.org>.
wangyum commented on PR #36373:
URL: https://github.com/apache/spark/pull/36373#issuecomment-2185948606
Hi @yaooqinn It will throw NPE if connect thriftserver through Hive 1.2.1 after this PR.
How to reproduce:
```
yumwang@G9L07H60PK apache-hive-1.2.1-bin % bin/beeline -u "jdbc:hive2://localhost:10000/"
ls: /Users/yumwang/Downloads/spark/lib/spark-assembly-*.jar: No such file or directory
Connecting to jdbc:hive2://localhost:10000/
Connected to: Spark SQL (version 3.5.0)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1 by Apache Hive
0: jdbc:hive2://localhost:10000/> use default;
java.lang.NullPointerException
at org.apache.hive.service.cli.ColumnBasedSet.<init>(ColumnBasedSet.java:50)
at org.apache.hive.service.cli.RowSetFactory.create(RowSetFactory.java:37)
at org.apache.hive.jdbc.HiveQueryResultSet.next(HiveQueryResultSet.java:368)
at org.apache.hive.beeline.BufferedRows.<init>(BufferedRows.java:42)
at org.apache.hive.beeline.BeeLine.print(BeeLine.java:1794)
at org.apache.hive.beeline.Commands.execute(Commands.java:860)
at org.apache.hive.beeline.Commands.sql(Commands.java:713)
at org.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:973)
at org.apache.hive.beeline.BeeLine.execute(BeeLine.java:813)
at org.apache.hive.beeline.BeeLine.begin(BeeLine.java:771)
at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:484)
at org.apache.hive.beeline.BeeLine.main(BeeLine.java:467)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Error: Error retrieving next row (state=,code=0)
```
Hive fixed this issue through HIVE-12049.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r859577346
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -373,17 +306,69 @@ private[hive] class SparkExecuteStatementOperation(
}
object SparkExecuteStatementOperation {
- def getTableSchema(structType: StructType): TableSchema = {
- val schema = structType.map { field =>
- val attrTypeString = field.dataType match {
- case CalendarIntervalType => StringType.catalogString
- case _: YearMonthIntervalType => "interval_year_month"
- case _: DayTimeIntervalType => "interval_day_time"
- case _: TimestampNTZType => "timestamp"
- case other => other.catalogString
- }
- new FieldSchema(field.name, attrTypeString, field.getComment.getOrElse(""))
+
+ def toTTypeId(typ: DataType): TTypeId = typ match {
+ case NullType => TTypeId.NULL_TYPE
+ case BooleanType => TTypeId.BOOLEAN_TYPE
+ case ByteType => TTypeId.TINYINT_TYPE
+ case ShortType => TTypeId.SMALLINT_TYPE
+ case IntegerType => TTypeId.INT_TYPE
+ case LongType => TTypeId.BIGINT_TYPE
+ case FloatType => TTypeId.FLOAT_TYPE
+ case DoubleType => TTypeId.DOUBLE_TYPE
+ case StringType => TTypeId.STRING_TYPE
+ case _: DecimalType => TTypeId.DECIMAL_TYPE
+ case DateType => TTypeId.DATE_TYPE
+ // TODO: Shall use TIMESTAMPLOCALTZ_TYPE, keep AS-IS now for
+ // unnecessary behavior change
+ case TimestampType => TTypeId.TIMESTAMP_TYPE
+ case TimestampNTZType => TTypeId.TIMESTAMP_TYPE
+ case BinaryType => TTypeId.BINARY_TYPE
+ case CalendarIntervalType => TTypeId.STRING_TYPE
+ case _: DayTimeIntervalType => TTypeId.INTERVAL_DAY_TIME_TYPE
+ case _: YearMonthIntervalType => TTypeId.INTERVAL_YEAR_MONTH_TYPE
+ case _: ArrayType => TTypeId.ARRAY_TYPE
+ case _: MapType => TTypeId.MAP_TYPE
+ case _: StructType => TTypeId.STRUCT_TYPE
+ case other =>
+ throw new IllegalArgumentException(s"Unrecognized type name: ${other.catalogString}")
+ }
+
+ private def toTTypeQualifiers(typ: DataType): TTypeQualifiers = {
+ val ret = new TTypeQualifiers()
+ val qualifiers = typ match {
+ case d: DecimalType =>
+ Map(
+ TCLIServiceConstants.PRECISION -> TTypeQualifierValue.i32Value(d.precision),
+ TCLIServiceConstants.SCALE -> TTypeQualifierValue.i32Value(d.scale)).asJava
+ case _ => Collections.emptyMap[String, TTypeQualifierValue]()
Review Comment:
if char/varchar can be seen via resultset metadata, we shall also provide the char length here for client to take advantage of it
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn closed pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
URL: https://github.com/apache/spark/pull/36373
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r859578656
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -373,17 +306,69 @@ private[hive] class SparkExecuteStatementOperation(
}
object SparkExecuteStatementOperation {
- def getTableSchema(structType: StructType): TableSchema = {
- val schema = structType.map { field =>
- val attrTypeString = field.dataType match {
- case CalendarIntervalType => StringType.catalogString
- case _: YearMonthIntervalType => "interval_year_month"
- case _: DayTimeIntervalType => "interval_day_time"
- case _: TimestampNTZType => "timestamp"
- case other => other.catalogString
- }
- new FieldSchema(field.name, attrTypeString, field.getComment.getOrElse(""))
+
+ def toTTypeId(typ: DataType): TTypeId = typ match {
+ case NullType => TTypeId.NULL_TYPE
+ case BooleanType => TTypeId.BOOLEAN_TYPE
+ case ByteType => TTypeId.TINYINT_TYPE
+ case ShortType => TTypeId.SMALLINT_TYPE
+ case IntegerType => TTypeId.INT_TYPE
+ case LongType => TTypeId.BIGINT_TYPE
+ case FloatType => TTypeId.FLOAT_TYPE
+ case DoubleType => TTypeId.DOUBLE_TYPE
+ case StringType => TTypeId.STRING_TYPE
+ case _: DecimalType => TTypeId.DECIMAL_TYPE
+ case DateType => TTypeId.DATE_TYPE
+ // TODO: Shall use TIMESTAMPLOCALTZ_TYPE, keep AS-IS now for
Review Comment:
TimestampType keeps being converted to TTypeId.TIMESTAMP_TYPE in this PR
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r871496811
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -373,17 +306,69 @@ private[hive] class SparkExecuteStatementOperation(
}
object SparkExecuteStatementOperation {
- def getTableSchema(structType: StructType): TableSchema = {
- val schema = structType.map { field =>
- val attrTypeString = field.dataType match {
- case CalendarIntervalType => StringType.catalogString
- case _: YearMonthIntervalType => "interval_year_month"
- case _: DayTimeIntervalType => "interval_day_time"
- case _: TimestampNTZType => "timestamp"
- case other => other.catalogString
- }
- new FieldSchema(field.name, attrTypeString, field.getComment.getOrElse(""))
+
+ def toTTypeId(typ: DataType): TTypeId = typ match {
+ case NullType => TTypeId.NULL_TYPE
+ case BooleanType => TTypeId.BOOLEAN_TYPE
+ case ByteType => TTypeId.TINYINT_TYPE
+ case ShortType => TTypeId.SMALLINT_TYPE
+ case IntegerType => TTypeId.INT_TYPE
+ case LongType => TTypeId.BIGINT_TYPE
+ case FloatType => TTypeId.FLOAT_TYPE
+ case DoubleType => TTypeId.DOUBLE_TYPE
+ case StringType => TTypeId.STRING_TYPE
+ case _: DecimalType => TTypeId.DECIMAL_TYPE
+ case DateType => TTypeId.DATE_TYPE
+ // TODO: Shall use TIMESTAMPLOCALTZ_TYPE, keep AS-IS now for
+ // unnecessary behavior change
+ case TimestampType => TTypeId.TIMESTAMP_TYPE
+ case TimestampNTZType => TTypeId.TIMESTAMP_TYPE
Review Comment:
this is for rowset schema. jdbc client side can call getString to get the raw string or getObject to get an java object where it is used
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r860899902
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/RowSetUtils.scala:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.nio.ByteBuffer
+
+import scala.collection.JavaConverters._
+import scala.language.implicitConversions
+
+import org.apache.hive.service.rpc.thrift._
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.execution.HiveResult.{toHiveString, TimeFormatters}
+import org.apache.spark.sql.types.{BinaryType, BooleanType, ByteType, DataType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType}
+
+object RowSetUtils {
+
+ implicit def bitSetToBuffer(bitSet: java.util.BitSet): ByteBuffer = {
+ ByteBuffer.wrap(bitSet.toByteArray)
+ }
+
+ def toTRowSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ protocolVersion: TProtocolVersion,
+ timeFormatters: TimeFormatters): TRowSet = {
+ if (protocolVersion.getValue < TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+ toRowBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ } else {
+ toColumnBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ }
+ }
+
+ private def toRowBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ var i = 0
+ val rowSize = rows.length
+ val tRows = new java.util.ArrayList[TRow](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ val tRow = new TRow()
+ var j = 0
+ val columnSize = row.length
+ while (j < columnSize) {
+ val columnValue = toTColumnValue(j, row, schema(j), timeFormatters)
+ tRow.addToColVals(columnValue)
+ j += 1
+ }
+ i += 1
+ tRows.add(tRow)
+ }
+ new TRowSet(startRowOffSet, tRows)
+ }
+
+ private def toColumnBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ val rowSize = rows.length
+ val tRowSet = new TRowSet(startRowOffSet, new java.util.ArrayList[TRow](rowSize))
+ var i = 0
+ val columnSize = schema.length
+ while (i < columnSize) {
+ val tColumn = toTColumn(rows, i, schema(i), timeFormatters)
+ tRowSet.addToColumns(tColumn)
+ i += 1
+ }
+ tRowSet
+ }
+
+ private def toTColumn(
+ rows: Seq[Row], ordinal: Int, typ: DataType, timeFormatters: TimeFormatters): TColumn = {
+ val nulls = new java.util.BitSet()
+ typ match {
+ case BooleanType =>
+ val values = getOrSetAsNull[java.lang.Boolean](rows, ordinal, nulls, true)
+ TColumn.boolVal(new TBoolColumn(values, nulls))
+
+ case ByteType =>
+ val values = getOrSetAsNull[java.lang.Byte](rows, ordinal, nulls, 0.toByte)
+ TColumn.byteVal(new TByteColumn(values, nulls))
+
+ case ShortType =>
+ val values = getOrSetAsNull[java.lang.Short](rows, ordinal, nulls, 0.toShort)
+ TColumn.i16Val(new TI16Column(values, nulls))
+
+ case IntegerType =>
+ val values = getOrSetAsNull[java.lang.Integer](rows, ordinal, nulls, 0)
+ TColumn.i32Val(new TI32Column(values, nulls))
+
+ case LongType =>
+ val values = getOrSetAsNull[java.lang.Long](rows, ordinal, nulls, 0L)
+ TColumn.i64Val(new TI64Column(values, nulls))
+
+ case FloatType =>
+ val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case DoubleType =>
+ val values = getOrSetAsNull[java.lang.Double](rows, ordinal, nulls, 0.toDouble)
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case StringType =>
+ val values = getOrSetAsNull[java.lang.String](rows, ordinal, nulls, "")
+ TColumn.stringVal(new TStringColumn(values, nulls))
+
+ case BinaryType =>
+ val values = getOrSetAsNull[Array[Byte]](rows, ordinal, nulls, Array.empty[Byte])
+ .asScala
+ .map(ByteBuffer.wrap)
+ .asJava
+ TColumn.binaryVal(new TBinaryColumn(values, nulls))
+
+ case _ =>
+ var i = 0
+ val rowSize = rows.length
+ val values = new java.util.ArrayList[String](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ nulls.set(i, row.isNullAt(ordinal))
+ val value = if (row.isNullAt(ordinal)) {
+ ""
+ } else {
+ toHiveString((row.get(ordinal), typ), nested = true, timeFormatters)
+ }
+ values.add(value)
+ i += 1
+ }
+ TColumn.stringVal(new TStringColumn(values, nulls))
+ }
+ }
+
+ private def getOrSetAsNull[T](
+ rows: Seq[Row],
+ ordinal: Int,
+ nulls: java.util.BitSet,
+ defaultVal: T): java.util.List[T] = {
+ val size = rows.length
+ val ret = new java.util.ArrayList[T](size)
+ var idx = 0
+ while (idx < size) {
+ val row = rows(idx)
+ if (row.isNullAt(ordinal)) {
+ nulls.set(idx, true)
+ ret.add(idx, defaultVal)
+ } else {
+ ret.add(idx, row.getAs[T](ordinal))
+ }
+ idx += 1
+ }
+ ret
+ }
+
+ private def toTColumnValue(
+ ordinal: Int,
+ row: Row,
Review Comment:
not related to this PR, but it seems more efficient if we can convert `InternalRow` directly to `TRowSet`
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r861445508
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/RowSetUtils.scala:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.nio.ByteBuffer
+
+import scala.collection.JavaConverters._
+import scala.language.implicitConversions
+
+import org.apache.hive.service.rpc.thrift._
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.execution.HiveResult.{toHiveString, TimeFormatters}
+import org.apache.spark.sql.types.{BinaryType, BooleanType, ByteType, DataType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType}
+
+object RowSetUtils {
+
+ implicit def bitSetToBuffer(bitSet: java.util.BitSet): ByteBuffer = {
+ ByteBuffer.wrap(bitSet.toByteArray)
+ }
+
+ def toTRowSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ protocolVersion: TProtocolVersion,
+ timeFormatters: TimeFormatters): TRowSet = {
+ if (protocolVersion.getValue < TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+ toRowBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ } else {
+ toColumnBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ }
+ }
+
+ private def toRowBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ var i = 0
+ val rowSize = rows.length
+ val tRows = new java.util.ArrayList[TRow](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ val tRow = new TRow()
+ var j = 0
+ val columnSize = row.length
+ while (j < columnSize) {
+ val columnValue = toTColumnValue(j, row, schema(j), timeFormatters)
+ tRow.addToColVals(columnValue)
+ j += 1
+ }
+ i += 1
+ tRows.add(tRow)
+ }
+ new TRowSet(startRowOffSet, tRows)
+ }
+
+ private def toColumnBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ val rowSize = rows.length
+ val tRowSet = new TRowSet(startRowOffSet, new java.util.ArrayList[TRow](rowSize))
+ var i = 0
+ val columnSize = schema.length
+ while (i < columnSize) {
+ val tColumn = toTColumn(rows, i, schema(i), timeFormatters)
+ tRowSet.addToColumns(tColumn)
+ i += 1
+ }
+ tRowSet
+ }
+
+ private def toTColumn(
+ rows: Seq[Row], ordinal: Int, typ: DataType, timeFormatters: TimeFormatters): TColumn = {
+ val nulls = new java.util.BitSet()
+ typ match {
+ case BooleanType =>
+ val values = getOrSetAsNull[java.lang.Boolean](rows, ordinal, nulls, true)
+ TColumn.boolVal(new TBoolColumn(values, nulls))
+
+ case ByteType =>
+ val values = getOrSetAsNull[java.lang.Byte](rows, ordinal, nulls, 0.toByte)
+ TColumn.byteVal(new TByteColumn(values, nulls))
+
+ case ShortType =>
+ val values = getOrSetAsNull[java.lang.Short](rows, ordinal, nulls, 0.toShort)
+ TColumn.i16Val(new TI16Column(values, nulls))
+
+ case IntegerType =>
+ val values = getOrSetAsNull[java.lang.Integer](rows, ordinal, nulls, 0)
+ TColumn.i32Val(new TI32Column(values, nulls))
+
+ case LongType =>
+ val values = getOrSetAsNull[java.lang.Long](rows, ordinal, nulls, 0L)
+ TColumn.i64Val(new TI64Column(values, nulls))
+
+ case FloatType =>
+ val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case DoubleType =>
+ val values = getOrSetAsNull[java.lang.Double](rows, ordinal, nulls, 0.toDouble)
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case StringType =>
+ val values = getOrSetAsNull[java.lang.String](rows, ordinal, nulls, "")
+ TColumn.stringVal(new TStringColumn(values, nulls))
+
+ case BinaryType =>
+ val values = getOrSetAsNull[Array[Byte]](rows, ordinal, nulls, Array.empty[Byte])
+ .asScala
+ .map(ByteBuffer.wrap)
+ .asJava
+ TColumn.binaryVal(new TBinaryColumn(values, nulls))
+
+ case _ =>
+ var i = 0
+ val rowSize = rows.length
+ val values = new java.util.ArrayList[String](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ nulls.set(i, row.isNullAt(ordinal))
+ val value = if (row.isNullAt(ordinal)) {
+ ""
+ } else {
+ toHiveString((row.get(ordinal), typ), nested = true, timeFormatters)
+ }
+ values.add(value)
+ i += 1
+ }
+ TColumn.stringVal(new TStringColumn(values, nulls))
+ }
+ }
+
+ private def getOrSetAsNull[T](
+ rows: Seq[Row],
+ ordinal: Int,
+ nulls: java.util.BitSet,
+ defaultVal: T): java.util.List[T] = {
+ val size = rows.length
+ val ret = new java.util.ArrayList[T](size)
+ var idx = 0
+ while (idx < size) {
+ val row = rows(idx)
+ if (row.isNullAt(ordinal)) {
+ nulls.set(idx, true)
+ ret.add(idx, defaultVal)
+ } else {
+ ret.add(idx, row.getAs[T](ordinal))
+ }
+ idx += 1
+ }
+ ret
+ }
+
+ private def toTColumnValue(
+ ordinal: Int,
+ row: Row,
+ dataType: DataType,
+ timeFormatters: TimeFormatters): TColumnValue = {
+ dataType match {
+ case BooleanType =>
+ val boolValue = new TBoolValue
+ if (!row.isNullAt(ordinal)) boolValue.setValue(row.getBoolean(ordinal))
+ TColumnValue.boolVal(boolValue)
+
+ case ByteType =>
+ val byteValue = new TByteValue
+ if (!row.isNullAt(ordinal)) byteValue.setValue(row.getByte(ordinal))
+ TColumnValue.byteVal(byteValue)
+
+ case ShortType =>
+ val tI16Value = new TI16Value
+ if (!row.isNullAt(ordinal)) tI16Value.setValue(row.getShort(ordinal))
+ TColumnValue.i16Val(tI16Value)
+
+ case IntegerType =>
+ val tI32Value = new TI32Value
+ if (!row.isNullAt(ordinal)) tI32Value.setValue(row.getInt(ordinal))
+ TColumnValue.i32Val(tI32Value)
+
+ case LongType =>
+ val tI64Value = new TI64Value
+ if (!row.isNullAt(ordinal)) tI64Value.setValue(row.getLong(ordinal))
+ TColumnValue.i64Val(tI64Value)
+
+ case FloatType =>
+ val tDoubleValue = new TDoubleValue
+ if (!row.isNullAt(ordinal)) {
+ val doubleValue = java.lang.Double.valueOf(row.getFloat(ordinal).toString)
Review Comment:
updated
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly [spark]
Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on PR #36373:
URL: https://github.com/apache/spark/pull/36373#issuecomment-2208498874
Hi @wangyum
Code in this PR 20c9b3dc4fac283f895c8d860b4c6e0144697302 shall work, I guess. But some of them got partially reverted by 91dfc31ff89c5fa024371484f6788234e4a3df10
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r871485266
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -373,17 +306,69 @@ private[hive] class SparkExecuteStatementOperation(
}
object SparkExecuteStatementOperation {
- def getTableSchema(structType: StructType): TableSchema = {
- val schema = structType.map { field =>
- val attrTypeString = field.dataType match {
- case CalendarIntervalType => StringType.catalogString
- case _: YearMonthIntervalType => "interval_year_month"
- case _: DayTimeIntervalType => "interval_day_time"
- case _: TimestampNTZType => "timestamp"
- case other => other.catalogString
- }
- new FieldSchema(field.name, attrTypeString, field.getComment.getOrElse(""))
+
+ def toTTypeId(typ: DataType): TTypeId = typ match {
+ case NullType => TTypeId.NULL_TYPE
+ case BooleanType => TTypeId.BOOLEAN_TYPE
+ case ByteType => TTypeId.TINYINT_TYPE
+ case ShortType => TTypeId.SMALLINT_TYPE
+ case IntegerType => TTypeId.INT_TYPE
+ case LongType => TTypeId.BIGINT_TYPE
+ case FloatType => TTypeId.FLOAT_TYPE
+ case DoubleType => TTypeId.DOUBLE_TYPE
+ case StringType => TTypeId.STRING_TYPE
+ case _: DecimalType => TTypeId.DECIMAL_TYPE
+ case DateType => TTypeId.DATE_TYPE
+ // TODO: Shall use TIMESTAMPLOCALTZ_TYPE, keep AS-IS now for
+ // unnecessary behavior change
+ case TimestampType => TTypeId.TIMESTAMP_TYPE
+ case TimestampNTZType => TTypeId.TIMESTAMP_TYPE
Review Comment:
Maybe I'm missing some context here. Looking at `RowSetUtils`, datetime types are use String as result. Where do we use `TTypeId`?
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkExecuteStatementOperation.scala:
##########
@@ -373,17 +306,69 @@ private[hive] class SparkExecuteStatementOperation(
}
object SparkExecuteStatementOperation {
- def getTableSchema(structType: StructType): TableSchema = {
- val schema = structType.map { field =>
- val attrTypeString = field.dataType match {
- case CalendarIntervalType => StringType.catalogString
- case _: YearMonthIntervalType => "interval_year_month"
- case _: DayTimeIntervalType => "interval_day_time"
- case _: TimestampNTZType => "timestamp"
- case other => other.catalogString
- }
- new FieldSchema(field.name, attrTypeString, field.getComment.getOrElse(""))
+
+ def toTTypeId(typ: DataType): TTypeId = typ match {
+ case NullType => TTypeId.NULL_TYPE
+ case BooleanType => TTypeId.BOOLEAN_TYPE
+ case ByteType => TTypeId.TINYINT_TYPE
+ case ShortType => TTypeId.SMALLINT_TYPE
+ case IntegerType => TTypeId.INT_TYPE
+ case LongType => TTypeId.BIGINT_TYPE
+ case FloatType => TTypeId.FLOAT_TYPE
+ case DoubleType => TTypeId.DOUBLE_TYPE
+ case StringType => TTypeId.STRING_TYPE
+ case _: DecimalType => TTypeId.DECIMAL_TYPE
+ case DateType => TTypeId.DATE_TYPE
+ // TODO: Shall use TIMESTAMPLOCALTZ_TYPE, keep AS-IS now for
+ // unnecessary behavior change
+ case TimestampType => TTypeId.TIMESTAMP_TYPE
+ case TimestampNTZType => TTypeId.TIMESTAMP_TYPE
Review Comment:
Maybe I'm missing some context here. Looking at `RowSetUtils`, datetime types are using String as result. Where do we use `TTypeId`?
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r871477878
##########
sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/session/HiveSession.java:
##########
@@ -182,11 +184,11 @@ OperationHandle getCrossReference(String primaryCatalog,
void closeOperation(OperationHandle opHandle) throws HiveSQLException;
- TableSchema getResultSetMetadata(OperationHandle opHandle)
+ TTableSchema getResultSetMetadata(OperationHandle opHandle)
throws HiveSQLException;
- RowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation,
- long maxRows, FetchType fetchType) throws HiveSQLException;
+ TRowSet fetchResults(OperationHandle opHandle, FetchOrientation orientation,
+ long maxRows, FetchType fetchType) throws HiveSQLException;
Review Comment:
the previous indentation was correct.
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] yaooqinn commented on a diff in pull request #36373: [SPARK-39041][SQL] Mapping Spark Query ResultSet/Schema to TRowSet/TTableSchema directly
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #36373:
URL: https://github.com/apache/spark/pull/36373#discussion_r860912047
##########
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/RowSetUtils.scala:
##########
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.thriftserver
+
+import java.nio.ByteBuffer
+
+import scala.collection.JavaConverters._
+import scala.language.implicitConversions
+
+import org.apache.hive.service.rpc.thrift._
+
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.execution.HiveResult.{toHiveString, TimeFormatters}
+import org.apache.spark.sql.types.{BinaryType, BooleanType, ByteType, DataType, DoubleType, FloatType, IntegerType, LongType, ShortType, StringType}
+
+object RowSetUtils {
+
+ implicit def bitSetToBuffer(bitSet: java.util.BitSet): ByteBuffer = {
+ ByteBuffer.wrap(bitSet.toByteArray)
+ }
+
+ def toTRowSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ protocolVersion: TProtocolVersion,
+ timeFormatters: TimeFormatters): TRowSet = {
+ if (protocolVersion.getValue < TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+ toRowBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ } else {
+ toColumnBasedSet(startRowOffSet, rows, schema, timeFormatters)
+ }
+ }
+
+ private def toRowBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ var i = 0
+ val rowSize = rows.length
+ val tRows = new java.util.ArrayList[TRow](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ val tRow = new TRow()
+ var j = 0
+ val columnSize = row.length
+ while (j < columnSize) {
+ val columnValue = toTColumnValue(j, row, schema(j), timeFormatters)
+ tRow.addToColVals(columnValue)
+ j += 1
+ }
+ i += 1
+ tRows.add(tRow)
+ }
+ new TRowSet(startRowOffSet, tRows)
+ }
+
+ private def toColumnBasedSet(
+ startRowOffSet: Long,
+ rows: Seq[Row],
+ schema: Array[DataType],
+ timeFormatters: TimeFormatters): TRowSet = {
+ val rowSize = rows.length
+ val tRowSet = new TRowSet(startRowOffSet, new java.util.ArrayList[TRow](rowSize))
+ var i = 0
+ val columnSize = schema.length
+ while (i < columnSize) {
+ val tColumn = toTColumn(rows, i, schema(i), timeFormatters)
+ tRowSet.addToColumns(tColumn)
+ i += 1
+ }
+ tRowSet
+ }
+
+ private def toTColumn(
+ rows: Seq[Row], ordinal: Int, typ: DataType, timeFormatters: TimeFormatters): TColumn = {
+ val nulls = new java.util.BitSet()
+ typ match {
+ case BooleanType =>
+ val values = getOrSetAsNull[java.lang.Boolean](rows, ordinal, nulls, true)
+ TColumn.boolVal(new TBoolColumn(values, nulls))
+
+ case ByteType =>
+ val values = getOrSetAsNull[java.lang.Byte](rows, ordinal, nulls, 0.toByte)
+ TColumn.byteVal(new TByteColumn(values, nulls))
+
+ case ShortType =>
+ val values = getOrSetAsNull[java.lang.Short](rows, ordinal, nulls, 0.toShort)
+ TColumn.i16Val(new TI16Column(values, nulls))
+
+ case IntegerType =>
+ val values = getOrSetAsNull[java.lang.Integer](rows, ordinal, nulls, 0)
+ TColumn.i32Val(new TI32Column(values, nulls))
+
+ case LongType =>
+ val values = getOrSetAsNull[java.lang.Long](rows, ordinal, nulls, 0L)
+ TColumn.i64Val(new TI64Column(values, nulls))
+
+ case FloatType =>
+ val values = getOrSetAsNull[java.lang.Float](rows, ordinal, nulls, 0.toFloat)
+ .asScala.map(n => java.lang.Double.valueOf(n.toString)).asJava
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case DoubleType =>
+ val values = getOrSetAsNull[java.lang.Double](rows, ordinal, nulls, 0.toDouble)
+ TColumn.doubleVal(new TDoubleColumn(values, nulls))
+
+ case StringType =>
+ val values = getOrSetAsNull[java.lang.String](rows, ordinal, nulls, "")
+ TColumn.stringVal(new TStringColumn(values, nulls))
+
+ case BinaryType =>
+ val values = getOrSetAsNull[Array[Byte]](rows, ordinal, nulls, Array.empty[Byte])
+ .asScala
+ .map(ByteBuffer.wrap)
+ .asJava
+ TColumn.binaryVal(new TBinaryColumn(values, nulls))
+
+ case _ =>
+ var i = 0
+ val rowSize = rows.length
+ val values = new java.util.ArrayList[String](rowSize)
+ while (i < rowSize) {
+ val row = rows(i)
+ nulls.set(i, row.isNullAt(ordinal))
+ val value = if (row.isNullAt(ordinal)) {
+ ""
+ } else {
+ toHiveString((row.get(ordinal), typ), nested = true, timeFormatters)
+ }
+ values.add(value)
+ i += 1
+ }
+ TColumn.stringVal(new TStringColumn(values, nulls))
+ }
+ }
+
+ private def getOrSetAsNull[T](
+ rows: Seq[Row],
+ ordinal: Int,
+ nulls: java.util.BitSet,
+ defaultVal: T): java.util.List[T] = {
+ val size = rows.length
+ val ret = new java.util.ArrayList[T](size)
+ var idx = 0
+ while (idx < size) {
+ val row = rows(idx)
+ if (row.isNullAt(ordinal)) {
+ nulls.set(idx, true)
+ ret.add(idx, defaultVal)
+ } else {
+ ret.add(idx, row.getAs[T](ordinal))
+ }
+ idx += 1
+ }
+ ret
+ }
+
+ private def toTColumnValue(
+ ordinal: Int,
+ row: Row,
+ dataType: DataType,
+ timeFormatters: TimeFormatters): TColumnValue = {
+ dataType match {
+ case BooleanType =>
+ val boolValue = new TBoolValue
+ if (!row.isNullAt(ordinal)) boolValue.setValue(row.getBoolean(ordinal))
+ TColumnValue.boolVal(boolValue)
+
+ case ByteType =>
+ val byteValue = new TByteValue
+ if (!row.isNullAt(ordinal)) byteValue.setValue(row.getByte(ordinal))
+ TColumnValue.byteVal(byteValue)
+
+ case ShortType =>
+ val tI16Value = new TI16Value
+ if (!row.isNullAt(ordinal)) tI16Value.setValue(row.getShort(ordinal))
+ TColumnValue.i16Val(tI16Value)
+
+ case IntegerType =>
+ val tI32Value = new TI32Value
+ if (!row.isNullAt(ordinal)) tI32Value.setValue(row.getInt(ordinal))
+ TColumnValue.i32Val(tI32Value)
+
+ case LongType =>
+ val tI64Value = new TI64Value
+ if (!row.isNullAt(ordinal)) tI64Value.setValue(row.getLong(ordinal))
+ TColumnValue.i64Val(tI64Value)
+
+ case FloatType =>
+ val tDoubleValue = new TDoubleValue
+ if (!row.isNullAt(ordinal)) {
+ val doubleValue = java.lang.Double.valueOf(row.getFloat(ordinal).toString)
Review Comment:
https://github.com/apache/incubator-kyuubi/issues/1784
precision loss prevention
--
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: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org