Skip to content

[SPARK-16429][SQL] Include StringType columns in describe()#14095

Closed
dongjoon-hyun wants to merge 4 commits into
apache:masterfrom
dongjoon-hyun:SPARK-16429
Closed

[SPARK-16429][SQL] Include StringType columns in describe()#14095
dongjoon-hyun wants to merge 4 commits into
apache:masterfrom
dongjoon-hyun:SPARK-16429

Conversation

@dongjoon-hyun

@dongjoon-hyun dongjoon-hyun commented Jul 7, 2016

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

Currently, Spark describe supports StringType. However, describe() returns a dataset for only all numeric columns. This PR aims to include StringType columns in describe(), describe without argument.

Background

scala> spark.read.json("examples/src/main/resources/people.json").describe("age", "name").show()
+-------+------------------+-------+
|summary|               age|   name|
+-------+------------------+-------+
|  count|                 2|      3|
|   mean|              24.5|   null|
| stddev|7.7781745930520225|   null|
|    min|                19|   Andy|
|    max|                30|Michael|
+-------+------------------+-------+

Before

scala> spark.read.json("examples/src/main/resources/people.json").describe().show()
+-------+------------------+
|summary|               age|
+-------+------------------+
|  count|                 2|
|   mean|              24.5|
| stddev|7.7781745930520225|
|    min|                19|
|    max|                30|
+-------+------------------+

After

scala> spark.read.json("examples/src/main/resources/people.json").describe().show()
+-------+------------------+-------+                                            
|summary|               age|   name|
+-------+------------------+-------+
|  count|                 2|      3|
|   mean|              24.5|   null|
| stddev|7.7781745930520225|   null|
|    min|                19|   Andy|
|    max|                30|Michael|
+-------+------------------+-------+

How was this patch tested?

Pass the Jenkins with a update testcase.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private rather than private sql?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be better.

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Thank you for fast review, @rxin . I updated it.

@SparkQA

SparkQA commented Jul 7, 2016

Copy link
Copy Markdown

Test build #61929 has finished for PR 14095 at commit df2edd7.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Oh, it's a documented behavior.

Computes statistics for **numeric** columns

@SparkQA

SparkQA commented Jul 7, 2016

Copy link
Copy Markdown

Test build #61930 has finished for PR 14095 at commit b6673cb.

  • This patch fails PySpark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun dongjoon-hyun changed the title [SPARK-16429][SQL] Include StringType columns in Scala/Python describe() [SPARK-16429][SQL] Include StringType columns in describe() Jul 7, 2016
@rxin

rxin commented Jul 8, 2016

Copy link
Copy Markdown
Contributor

Can you fix Python?

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Oh, sure!

@rxin

rxin commented Jul 8, 2016

Copy link
Copy Markdown
Contributor

And also update the documentation.

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Of course!

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

I fixed Python/R and the docs accordingly, and tested locally.

.filter(f => f.dataType.isInstanceOf[NumericType] || f.dataType.isInstanceOf[StringType])
.map { n =>
queryExecution.analyzed.resolveQuoted(n.name, sparkSession.sessionState.analyzer.resolver)
.get

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible that this would fail?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ur, this is an direct extension of line 225 of existing numericColumns.

https://github.com/apache/spark/pull/14095/files#diff-7a46f10c3cedbf013cf255564d9483cdR225

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the failure of resolveQuoted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not fail because the names come from schema.fields.

@SparkQA

SparkQA commented Jul 8, 2016

Copy link
Copy Markdown

Test build #61962 has finished for PR 14095 at commit 8915adb.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Hi, @rxin .
It's ready for review again.

@SparkQA

SparkQA commented Jul 8, 2016

Copy link
Copy Markdown

Test build #61965 has finished for PR 14095 at commit fa4d3b4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@rxin

rxin commented Jul 8, 2016

Copy link
Copy Markdown
Contributor

Thanks - merging in master.

@asfgit asfgit closed this in 142df48 Jul 8, 2016
@dongjoon-hyun

Copy link
Copy Markdown
Member Author

Thank you for merging, @rxin .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants