[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-26 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/spark/pull/14302


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-25 Thread liancheng
Github user liancheng commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r72071947
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -520,7 +522,7 @@ case class DescribeTableCommand(table: TableIdentifier, 
isExtended: Boolean, isF
 
   private def describeSchema(schema: Seq[CatalogColumn], buffer: 
ArrayBuffer[Row]): Unit = {
 schema.foreach { column =>
-  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.orNull)
+  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.getOrElse(""))
--- End diff --

I'm not sure whether no comment or empty comment matters here though. Maybe 
making them consistent makes more sense here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-25 Thread liancheng
Github user liancheng commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r72070878
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -436,11 +436,13 @@ case class DescribeTableCommand(table: 
TableIdentifier, isExtended: Boolean, isF
 
   private def describePartitionInfo(table: CatalogTable, buffer: 
ArrayBuffer[Row]): Unit = {
 if (DDLUtils.isDatasourceTable(table)) {
-  val partCols = DDLUtils.getPartitionColumnsFromTableProperties(table)
-  if (partCols.nonEmpty) {
+  val schema = DDLUtils.getSchemaFromTableProperties(table)
+  val partColNames = 
DDLUtils.getPartitionColumnsFromTableProperties(table)
+  if (partColNames.nonEmpty && schema.isDefined) {
 append(buffer, "# Partition Information", "", "")
-append(buffer, s"# ${output.head.name}", "", "")
-partCols.foreach(col => append(buffer, col, "", ""))
+append(buffer, s"# ${output.head.name}", output(1).name, 
output(2).name)
+val partCols = partColNames.map(n => schema.get.find(_.name == 
n).get)
--- End diff --

I'd rewrite the whole `if` as following:

```scala
for (s <- schema if partColNames.nonEmpty) {
  append(buffer, "# Partition Information", "", "")
  append(buffer, s"# ${output.head.name}", output(1).name, output(2).name)
  describeSchema(StructType(partColNames.map(s(_
}
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-25 Thread liancheng
Github user liancheng commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r72069708
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -520,7 +522,7 @@ case class DescribeTableCommand(table: TableIdentifier, 
isExtended: Boolean, isF
 
   private def describeSchema(schema: Seq[CatalogColumn], buffer: 
ArrayBuffer[Row]): Unit = {
 schema.foreach { column =>
-  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.orNull)
+  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.getOrElse(""))
--- End diff --

TBH, I just followed the original logic while rewriting this part and used 
null here. Technically, null means no comment, which is different from empty 
comment.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-24 Thread cloud-fan
Github user cloud-fan commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r72001037
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -520,7 +522,7 @@ case class DescribeTableCommand(table: TableIdentifier, 
isExtended: Boolean, isF
 
   private def describeSchema(schema: Seq[CatalogColumn], buffer: 
ArrayBuffer[Row]): Unit = {
 schema.foreach { column =>
-  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.orNull)
+  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.getOrElse(""))
--- End diff --

I don't have a strong preference here, cc @liancheng what do you think?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-24 Thread yhuai
Github user yhuai commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r71995943
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -520,7 +522,7 @@ case class DescribeTableCommand(table: TableIdentifier, 
isExtended: Boolean, isF
 
   private def describeSchema(schema: Seq[CatalogColumn], buffer: 
ArrayBuffer[Row]): Unit = {
 schema.foreach { column =>
-  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.orNull)
+  append(buffer, column.name, column.dataType.toLowerCase, 
column.comment.getOrElse(""))
--- End diff --

Seems using null is better?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-22 Thread jaceklaskowski
Github user jaceklaskowski commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r71886372
  
--- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveOperatorQueryableSuite.scala
 ---
@@ -41,13 +41,13 @@ class HiveOperatorQueryableSuite extends QueryTest with 
TestHiveSingleton {
 checkAnswer(
   sql("select * from mydesc"),
   Seq(
-Row("key", "int", null),
-Row("value", "string", null)))
+Row("key", "int", ""),
--- End diff --

Wish there were a "better" variant of `Row` as we traded `null`s to `""` :(


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-22 Thread jaceklaskowski
Github user jaceklaskowski commented on a diff in the pull request:

https://github.com/apache/spark/pull/14302#discussion_r71885483
  
--- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/command/tables.scala ---
@@ -436,11 +436,13 @@ case class DescribeTableCommand(table: 
TableIdentifier, isExtended: Boolean, isF
 
   private def describePartitionInfo(table: CatalogTable, buffer: 
ArrayBuffer[Row]): Unit = {
 if (DDLUtils.isDatasourceTable(table)) {
-  val partCols = DDLUtils.getPartitionColumnsFromTableProperties(table)
-  if (partCols.nonEmpty) {
+  val schema = DDLUtils.getSchemaFromTableProperties(table)
+  val partColNames = 
DDLUtils.getPartitionColumnsFromTableProperties(table)
+  if (partColNames.nonEmpty && schema.isDefined) {
 append(buffer, "# Partition Information", "", "")
-append(buffer, s"# ${output.head.name}", "", "")
-partCols.foreach(col => append(buffer, col, "", ""))
+append(buffer, s"# ${output.head.name}", output(1).name, 
output(2).name)
+val partCols = partColNames.map(n => schema.get.find(_.name == 
n).get)
--- End diff --

What do you think about this?

```
val s = schema.get
s.fieldNames.intersect(partColNames).map(s.apply)
```



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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



[GitHub] spark pull request #14302: [SPARK-16663][SQL] desc table should be consisten...

2016-07-21 Thread cloud-fan
GitHub user cloud-fan opened a pull request:

https://github.com/apache/spark/pull/14302

[SPARK-16663][SQL] desc table should be consistent between data source and 
hive serde tables

## What changes were proposed in this pull request?

Currently there are 2 inconsistence:

1. for data source table, we only print partition names, for hive table, we 
also print partition schema
2. if column doesn't have comment, data source table will print empty 
string, hive table will print null.

## How was this patch tested?

new test in `HiveDDLSuite`


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/cloud-fan/spark minor3

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/spark/pull/14302.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #14302


commit 090b1094533aec79fca53492e0a0e38e4c92f43c
Author: Wenchen Fan 
Date:   2016-07-21T13:12:50Z

desc table should be consistent between data source and hive serde tables




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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