spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [spark] AngersZhuuuu commented on a change in pull request #26340: [WIP][SPARK-29108][SQL] Add new module sql/thriftserver with all code and UT
Date Fri, 01 Nov 2019 13:32:51 GMT
AngersZhuuuu commented on a change in pull request #26340: [WIP][SPARK-29108][SQL] Add new
module sql/thriftserver  with all code and UT
URL: https://github.com/apache/spark/pull/26340#discussion_r341572757
 
 

 ##########
 File path: sql/thriftserver/src/main/scala/org/apache/spark/sql/thriftserver/cli/RowSetFactory.scala
 ##########
 @@ -0,0 +1,102 @@
+/*
+ * 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.thriftserver.cli
+
+import java.io.ByteArrayInputStream
+import java.util
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.thrift.TException
+import org.apache.thrift.protocol.TCompactProtocol
+import org.apache.thrift.transport.TIOStreamTransport
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.Row
+import org.apache.spark.sql.thriftserver.cli.thrift.{TColumn, TProtocolVersion, TRowSet}
+import org.apache.spark.sql.thriftserver.cli.thrift.TProtocolVersion._
+import org.apache.spark.sql.types.StructType
+
+private[thriftserver] object RowSetFactory extends Logging {
+  def create(types: StructType, rows: Seq[Row], version: TProtocolVersion): RowSet = {
+    if (version.getValue >= HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+      ColumnBasedSet(types, ArrayBuffer(rows: _*), 0)
+    } else {
+      RowBasedSet(types, ArrayBuffer(rows: _*), 0)
+    }
+  }
+
+  def create(types: StructType, version: TProtocolVersion): RowSet = {
+    if (version.getValue >= HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+      ColumnBasedSet(types, new ArrayBuffer[Row](), 0)
+    } else {
+      RowBasedSet(types, new ArrayBuffer[Row](), 0)
+    }
+  }
+
+  def create(tRowSet: TRowSet, version: TProtocolVersion): RowSet = {
+    val rows = new ArrayBuffer[Row]()
+    if (version.getValue >= HIVE_CLI_SERVICE_PROTOCOL_V6.getValue) {
+      if (tRowSet.isSetBinaryColumns) {
 
 Review comment:
   > In Hive the handling of this is inside ColumnaBased set. I think it should be put
there to keep this factory class simple.
   > 
   > Also, I think Spark will never use it server side, and this code is only for the client
reading it from a server that used it, so Spark could also maybe drop it...
   
   If we want to build spark's own jdbc client, we need these code.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message