yaooqinn commented on a change in pull request #29303:
URL: https://github.com/apache/spark/pull/29303#discussion_r463487940



##########
File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetColumnsOperation.scala
##########
@@ -126,12 +124,47 @@ private[hive] class SparkGetColumnsOperation(
     HiveThriftServer2.eventManager.onStatementFinish(statementId)
   }
 
+  private def getColumnSize(typ: DataType): Option[Int] = typ match {
+    case StringType | BinaryType => None
+    case ArrayType(et, _) => getColumnSize(et)
+    case MapType(kt, vt, _) =>
+      val kSize = getColumnSize(kt)
+      val vSize = getColumnSize(vt)
+      if (kSize.isEmpty || vSize.isEmpty) {
+        None
+      } else {
+        Some(kSize.get + vSize.get)
+      }
+    case StructType(fields) =>
+      val sizeArr = fields.map(f => getColumnSize(f.dataType))
+      if (sizeArr.contains(None)) {
+        None
+      } else {
+        Some(sizeArr.map(_.get).sum)
+      }
+    case other => Some(other.defaultSize)
+  }
+
+  private def getDecimalDigits(typ: DataType): Option[Int] = typ match {
+    case BooleanType | _: IntegerType => Some(0)
+    case FloatType => Some(7)
+    case DoubleType => Some(15)

Review comment:
       the result is `0.12345678901234568` which have 17 decimal digits but 
hive says its 15 for double...

##########
File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/SparkGetColumnsOperation.scala
##########
@@ -126,12 +124,47 @@ private[hive] class SparkGetColumnsOperation(
     HiveThriftServer2.eventManager.onStatementFinish(statementId)
   }
 
+  private def getColumnSize(typ: DataType): Option[Int] = typ match {
+    case StringType | BinaryType => None
+    case ArrayType(et, _) => getColumnSize(et)
+    case MapType(kt, vt, _) =>
+      val kSize = getColumnSize(kt)
+      val vSize = getColumnSize(vt)
+      if (kSize.isEmpty || vSize.isEmpty) {
+        None
+      } else {
+        Some(kSize.get + vSize.get)
+      }
+    case StructType(fields) =>
+      val sizeArr = fields.map(f => getColumnSize(f.dataType))
+      if (sizeArr.contains(None)) {
+        None
+      } else {
+        Some(sizeArr.map(_.get).sum)
+      }
+    case other => Some(other.defaultSize)
+  }
+
+  private def getDecimalDigits(typ: DataType): Option[Int] = typ match {
+    case BooleanType | _: IntegerType => Some(0)
+    case FloatType => Some(7)
+    case DoubleType => Some(15)

Review comment:
       the result is `0.12345678901234568` which have 17 decimal digits but 
hive says it's 15 for double...




----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to