You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by liancheng <gi...@git.apache.org> on 2016/02/29 13:38:36 UTC
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
GitHub user liancheng opened a pull request:
https://github.com/apache/spark/pull/11431
[SPARK-13553][SPARK-13554][SQL] Migrates basic inspection and typed relational operations from DataFrame to Dataset
## What changes were proposed in this pull request?
This PR migrates basic inspection and typed relational operations from DataFrame to Dataset. This is the first step of unifying DataFrame and Dataset API.
## TODO
- [ ] Migrate `explode` operations.
## How was this patch tested?
Corresponding test cases are migrated from `DataFrameSuite` to `DatasetSuite`. These newly added test cases all share the same "df-to-ds" prefix so that we can easily execute them under SBT using:
```
sql/test-only *.DatasetSuite -- -z "df-to-ds"
```
This prefix will be removed after migrating all the DataFrame operations.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/liancheng/spark df-to-ds-typed-relational
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/11431.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 #11431
----
commit 3f59569e8a0ab97beed2c6bb03c430b51fd94c3c
Author: Cheng Lian <li...@databricks.com>
Date: 2016-02-28T08:50:32Z
Migrates basic DataFrame inspection methods to Dataset
commit f38c016faea7e881202762a3bdd0db07a17cce8f
Author: Cheng Lian <li...@databricks.com>
Date: 2016-02-28T18:52:43Z
Migrates basic inspection and typed relational DF operations to DS
----
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190324737
**[Test build #52191 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52191/consoleFull)** for PR 11431 at commit [`6cb945f`](https://github.com/apache/spark/commit/6cb945fce95ce3787391dc9b84d1be31ea3e02f9).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190232826
**[Test build #52188 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52188/consoleFull)** for PR 11431 at commit [`ee9c432`](https://github.com/apache/spark/commit/ee9c432a1bde3cb4e8be090c6fd1bae3e41e9e98).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190367720
Merged build finished. Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190230395
Merged build finished. Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190230398
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52187/
Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190305317
Can you rebase to get rid of the merged commit?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54792050
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -101,19 +105,62 @@ class Dataset[T] private[sql](
* Prints the schema of the underlying [[Dataset]] to the console in a nice tree format.
* @since 1.6.0
*/
- override def printSchema(): Unit = toDF().printSchema()
+ // scalastyle:off println
+ override def printSchema(): Unit = println(schema.treeString)
+ // scalastyle:on println
/**
* Prints the plans (logical and physical) to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(extended: Boolean): Unit = toDF().explain(extended)
+ override def explain(extended: Boolean): Unit = {
+ val explain = ExplainCommand(queryExecution.logical, extended = extended)
+ sqlContext.executePlan(explain).executedPlan.executeCollect().foreach {
+ // scalastyle:off println
+ r => println(r.getString(0))
+ // scalastyle:on println
+ }
+ }
/**
* Prints the physical plan to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(): Unit = toDF().explain()
+ override def explain(): Unit = explain(extended = false)
+
+ /**
+ * Returns all column names and their data types as an array.
+ * @since 2.0.0
--- End diff --
Yea I'd just have it as 2.0.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190229980
**[Test build #52187 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52187/consoleFull)** for PR 11431 at commit [`f38c016`](https://github.com/apache/spark/commit/f38c016faea7e881202762a3bdd0db07a17cce8f).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54555208
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -574,6 +647,162 @@ class Dataset[T] private[sql](
sample(withReplacement, fraction, Utils.random.nextLong)
}
+ /**
+ * Filters rows using the given condition.
+ * {{{
+ * // The following are equivalent:
+ * peopleDs.filter($"age" > 15)
+ * peopleDs.where($"age" > 15)
+ * }}}
+ * @since 2.0.0
+ */
+ def filter(condition: Column): Dataset[T] = withPlan(Filter(condition.expr, _))
+
+ /**
+ * Filters rows using the given SQL expression.
+ * {{{
+ * peopleDs.filter("age > 15")
+ * }}}
+ * @since 2.0.0
+ */
+ def filter(conditionExpr: String): Dataset[T] = {
+ filter(Column(sqlContext.sqlParser.parseExpression(conditionExpr)))
+ }
+
+ /**
+ * Filters rows using the given condition. This is an alias for `filter`.
+ * {{{
+ * // The following are equivalent:
+ * peopleDs.filter($"age" > 15)
+ * peopleDs.where($"age" > 15)
+ * }}}
+ * @since 2.0.0
+ */
+ def where(condition: Column): Dataset[T] = filter(condition)
+
+ /**
+ * Filters rows using the given SQL expression.
+ * {{{
+ * peopleDs.where("age > 15")
+ * }}}
+ * @since 2.0.0
+ */
+ def where(conditionExpr: String): Dataset[T] = filter(conditionExpr)
+
+ /**
+ * Returns a new [[Dataset]] by taking the first `n` rows. The difference between this function
+ * and `head` is that `head` returns an array while `limit` returns a new [[Dataset]].
+ * @since 2.0.0
+ */
+ def limit(n: Int): Dataset[T] = withPlan(Limit(Literal(n), _))
+
+ /**
+ * Returns a new [[Dataset]] with each partition sorted by the given expressions.
+ *
+ * This is the same operation as "SORT BY" in SQL (Hive QL).
+ *
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sortWithinPartitions(sortCol: String, sortCols: String*): Dataset[T] = {
+ sortWithinPartitions((sortCol +: sortCols).map(Column(_)) : _*)
+ }
+
+ /**
+ * Returns a new [[Dataset]] with each partition sorted by the given expressions.
+ *
+ * This is the same operation as "SORT BY" in SQL (Hive QL).
+ *
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sortWithinPartitions(sortExprs: Column*): Dataset[T] = {
+ sortInternal(global = false, sortExprs)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the specified column, all in ascending order.
+ * {{{
+ * // The following 3 are equivalent
+ * ds.sort("sortcol")
+ * ds.sort($"sortcol")
+ * ds.sort($"sortcol".asc)
+ * }}}
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sort(sortCol: String, sortCols: String*): Dataset[T] = {
+ sort((sortCol +: sortCols).map(apply) : _*)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions. For example:
+ * {{{
+ * ds.sort($"col1", $"col2".desc)
+ * }}}
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sort(sortExprs: Column*): Dataset[T] = {
+ sortInternal(global = true, sortExprs)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions.
+ * This is an alias of the `sort` function.
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def orderBy(sortCol: String, sortCols: String*): Dataset[T] = sort(sortCol, sortCols : _*)
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions.
+ * This is an alias of the `sort` function.
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def orderBy(sortExprs: Column*): Dataset[T] = sort(sortExprs : _*)
+
+ /**
+ * Randomly splits this [[Dataset]] with the provided weights.
+ *
+ * @param weights weights for splits, will be normalized if they don't sum to 1.
+ * @param seed Seed for sampling.
+ * @since 2.0.0
+ */
+ def randomSplit(weights: Array[Double], seed: Long): Array[Dataset[T]] = {
+ // It is possible that the underlying Dataset doesn't guarantee the ordering of rows in its
+ // constituent partitions each time a split is materialized which could result in
+ // overlapping splits. To prevent this, we explicitly sort each input partition to make the
+ // ordering deterministic.
+ val sorted = Sort(logicalPlan.output.map(SortOrder(_, Ascending)), global = false, logicalPlan)
+ val sum = weights.sum
+ val normalizedCumWeights = weights.map(_ / sum).scanLeft(0.0d)(_ + _)
+ normalizedCumWeights.sliding(2).map { x =>
+ new Dataset(sqlContext, Sample(x(0), x(1), withReplacement = false, seed, sorted)())
--- End diff --
No, there's an implicit encoder defined in the constructor of Dataset.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54790200
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -101,19 +105,62 @@ class Dataset[T] private[sql](
* Prints the schema of the underlying [[Dataset]] to the console in a nice tree format.
* @since 1.6.0
*/
- override def printSchema(): Unit = toDF().printSchema()
+ // scalastyle:off println
+ override def printSchema(): Unit = println(schema.treeString)
+ // scalastyle:on println
/**
* Prints the plans (logical and physical) to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(extended: Boolean): Unit = toDF().explain(extended)
+ override def explain(extended: Boolean): Unit = {
+ val explain = ExplainCommand(queryExecution.logical, extended = extended)
+ sqlContext.executePlan(explain).executedPlan.executeCollect().foreach {
+ // scalastyle:off println
+ r => println(r.getString(0))
+ // scalastyle:on println
+ }
+ }
/**
* Prints the physical plan to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(): Unit = toDF().explain()
+ override def explain(): Unit = explain(extended = false)
+
+ /**
+ * Returns all column names and their data types as an array.
+ * @since 2.0.0
--- End diff --
I'd put 2.0 since it didn't exist on dataset before.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190195240
**[Test build #52187 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52187/consoleFull)** for PR 11431 at commit [`f38c016`](https://github.com/apache/spark/commit/f38c016faea7e881202762a3bdd0db07a17cce8f).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190233234
Merged build finished. Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54478929
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -574,6 +647,162 @@ class Dataset[T] private[sql](
sample(withReplacement, fraction, Utils.random.nextLong)
}
+ /**
+ * Filters rows using the given condition.
+ * {{{
+ * // The following are equivalent:
+ * peopleDs.filter($"age" > 15)
+ * peopleDs.where($"age" > 15)
+ * }}}
+ * @since 2.0.0
+ */
+ def filter(condition: Column): Dataset[T] = withPlan(Filter(condition.expr, _))
+
+ /**
+ * Filters rows using the given SQL expression.
+ * {{{
+ * peopleDs.filter("age > 15")
+ * }}}
+ * @since 2.0.0
+ */
+ def filter(conditionExpr: String): Dataset[T] = {
+ filter(Column(sqlContext.sqlParser.parseExpression(conditionExpr)))
+ }
+
+ /**
+ * Filters rows using the given condition. This is an alias for `filter`.
+ * {{{
+ * // The following are equivalent:
+ * peopleDs.filter($"age" > 15)
+ * peopleDs.where($"age" > 15)
+ * }}}
+ * @since 2.0.0
+ */
+ def where(condition: Column): Dataset[T] = filter(condition)
+
+ /**
+ * Filters rows using the given SQL expression.
+ * {{{
+ * peopleDs.where("age > 15")
+ * }}}
+ * @since 2.0.0
+ */
+ def where(conditionExpr: String): Dataset[T] = filter(conditionExpr)
+
+ /**
+ * Returns a new [[Dataset]] by taking the first `n` rows. The difference between this function
+ * and `head` is that `head` returns an array while `limit` returns a new [[Dataset]].
+ * @since 2.0.0
+ */
+ def limit(n: Int): Dataset[T] = withPlan(Limit(Literal(n), _))
+
+ /**
+ * Returns a new [[Dataset]] with each partition sorted by the given expressions.
+ *
+ * This is the same operation as "SORT BY" in SQL (Hive QL).
+ *
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sortWithinPartitions(sortCol: String, sortCols: String*): Dataset[T] = {
+ sortWithinPartitions((sortCol +: sortCols).map(Column(_)) : _*)
+ }
+
+ /**
+ * Returns a new [[Dataset]] with each partition sorted by the given expressions.
+ *
+ * This is the same operation as "SORT BY" in SQL (Hive QL).
+ *
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sortWithinPartitions(sortExprs: Column*): Dataset[T] = {
+ sortInternal(global = false, sortExprs)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the specified column, all in ascending order.
+ * {{{
+ * // The following 3 are equivalent
+ * ds.sort("sortcol")
+ * ds.sort($"sortcol")
+ * ds.sort($"sortcol".asc)
+ * }}}
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sort(sortCol: String, sortCols: String*): Dataset[T] = {
+ sort((sortCol +: sortCols).map(apply) : _*)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions. For example:
+ * {{{
+ * ds.sort($"col1", $"col2".desc)
+ * }}}
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def sort(sortExprs: Column*): Dataset[T] = {
+ sortInternal(global = true, sortExprs)
+ }
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions.
+ * This is an alias of the `sort` function.
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def orderBy(sortCol: String, sortCols: String*): Dataset[T] = sort(sortCol, sortCols : _*)
+
+ /**
+ * Returns a new [[Dataset]] sorted by the given expressions.
+ * This is an alias of the `sort` function.
+ * @since 2.0.0
+ */
+ @scala.annotation.varargs
+ def orderBy(sortExprs: Column*): Dataset[T] = sort(sortExprs : _*)
+
+ /**
+ * Randomly splits this [[Dataset]] with the provided weights.
+ *
+ * @param weights weights for splits, will be normalized if they don't sum to 1.
+ * @param seed Seed for sampling.
+ * @since 2.0.0
+ */
+ def randomSplit(weights: Array[Double], seed: Long): Array[Dataset[T]] = {
+ // It is possible that the underlying Dataset doesn't guarantee the ordering of rows in its
+ // constituent partitions each time a split is materialized which could result in
+ // overlapping splits. To prevent this, we explicitly sort each input partition to make the
+ // ordering deterministic.
+ val sorted = Sort(logicalPlan.output.map(SortOrder(_, Ascending)), global = false, logicalPlan)
+ val sum = weights.sum
+ val normalizedCumWeights = weights.map(_ / sum).scanLeft(0.0d)(_ + _)
+ normalizedCumWeights.sliding(2).map { x =>
+ new Dataset(sqlContext, Sample(x(0), x(1), withReplacement = false, seed, sorted)())
--- End diff --
Do we need to pass encoder into newly created Datasets at 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190197406
**[Test build #52188 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52188/consoleFull)** for PR 11431 at commit [`ee9c432`](https://github.com/apache/spark/commit/ee9c432a1bde3cb4e8be090c6fd1bae3e41e9e98).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54405042
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -138,13 +185,6 @@ class Dataset[T] private[sql](
}
/**
- * Applies a logical alias to this [[Dataset]] that can be used to disambiguate columns that have
- * the same name after two Datasets have been joined.
- * @since 1.6.0
- */
- def as(alias: String): Dataset[T] = withPlan(SubqueryAlias(alias, _))
-
- /**
--- End diff --
This method is moved to the Typed Relational section.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190324641
@liancheng I just pushed two commits to resolve the conflicts.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54555140
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala ---
@@ -627,6 +662,181 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
Seq(OuterObject.InnerClass("foo")).toDS(),
OuterObject.InnerClass("foo"))
}
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Tests for operations migrated from DataFrame
+ /////////////////////////////////////////////////////////////////////////////
+
+ test("column selection") {
+ val df = Seq(Tuple1(1)).toDS().as("t")
+ // We should allow empty string as column name
--- End diff --
Copy paste error. Should remove this.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190233245
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52188/
Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54782751
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -101,19 +105,62 @@ class Dataset[T] private[sql](
* Prints the schema of the underlying [[Dataset]] to the console in a nice tree format.
* @since 1.6.0
*/
- override def printSchema(): Unit = toDF().printSchema()
+ // scalastyle:off println
+ override def printSchema(): Unit = println(schema.treeString)
+ // scalastyle:on println
/**
* Prints the plans (logical and physical) to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(extended: Boolean): Unit = toDF().explain(extended)
+ override def explain(extended: Boolean): Unit = {
+ val explain = ExplainCommand(queryExecution.logical, extended = extended)
+ sqlContext.executePlan(explain).executedPlan.executeCollect().foreach {
+ // scalastyle:off println
+ r => println(r.getString(0))
+ // scalastyle:on println
+ }
+ }
/**
* Prints the physical plan to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(): Unit = toDF().explain()
+ override def explain(): Unit = explain(extended = false)
+
+ /**
+ * Returns all column names and their data types as an array.
+ * @since 2.0.0
--- End diff --
If the API is moved from DataFrame, should we also copy the `@since`?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng closed the pull request at:
https://github.com/apache/spark/pull/11431
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54790953
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -101,19 +105,62 @@ class Dataset[T] private[sql](
* Prints the schema of the underlying [[Dataset]] to the console in a nice tree format.
* @since 1.6.0
*/
- override def printSchema(): Unit = toDF().printSchema()
+ // scalastyle:off println
+ override def printSchema(): Unit = println(schema.treeString)
+ // scalastyle:on println
/**
* Prints the plans (logical and physical) to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(extended: Boolean): Unit = toDF().explain(extended)
+ override def explain(extended: Boolean): Unit = {
+ val explain = ExplainCommand(queryExecution.logical, extended = extended)
+ sqlContext.executePlan(explain).executedPlan.executeCollect().foreach {
+ // scalastyle:off println
+ r => println(r.getString(0))
+ // scalastyle:on println
+ }
+ }
/**
* Prints the physical plan to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(): Unit = toDF().explain()
+ override def explain(): Unit = explain(extended = false)
+
+ /**
+ * Returns all column names and their data types as an array.
+ * @since 2.0.0
--- End diff --
Since DataFrame will be an alias of Dataset, what will the doc for DataFrame looks like?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-195130198
Closing this in favor of #11443.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by liancheng <gi...@git.apache.org>.
Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54404408
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala ---
@@ -559,7 +561,11 @@ class Analyzer(
}
resolveExpression(unbound, LocalRelation(attributes), throws = true) transform {
- case n: NewInstance if n.outerPointer.isEmpty && n.cls.isMemberClass =>
+ case n: NewInstance
+ if n.outerPointer.isEmpty &&
+ n.cls.isMemberClass &&
+ !Modifier.isStatic(n.cls.getModifiers) =>
+ n.cls.getEnclosingClass
--- End diff --
This change is included in PR #11421. Without this fix, we can't use case classes defined in `SQLTestData` as Dataset element type.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54791219
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/Dataset.scala ---
@@ -101,19 +105,62 @@ class Dataset[T] private[sql](
* Prints the schema of the underlying [[Dataset]] to the console in a nice tree format.
* @since 1.6.0
*/
- override def printSchema(): Unit = toDF().printSchema()
+ // scalastyle:off println
+ override def printSchema(): Unit = println(schema.treeString)
+ // scalastyle:on println
/**
* Prints the plans (logical and physical) to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(extended: Boolean): Unit = toDF().explain(extended)
+ override def explain(extended: Boolean): Unit = {
+ val explain = ExplainCommand(queryExecution.logical, extended = extended)
+ sqlContext.executePlan(explain).executedPlan.executeCollect().foreach {
+ // scalastyle:off println
+ r => println(r.getString(0))
+ // scalastyle:on println
+ }
+ }
/**
* Prints the physical plan to the console for debugging purposes.
* @since 1.6.0
*/
- override def explain(): Unit = toDF().explain()
+ override def explain(): Unit = explain(extended = false)
+
+ /**
+ * Returns all column names and their data types as an array.
+ * @since 2.0.0
--- End diff --
If we copy the versions, It's also weird that see a method of Dataset (1.3) is introduced before Dataset is introduced (1.6).
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190367724
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/52191/
Test PASSed.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by yhuai <gi...@git.apache.org>.
Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/11431#discussion_r54482417
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala ---
@@ -627,6 +662,181 @@ class DatasetSuite extends QueryTest with SharedSQLContext {
Seq(OuterObject.InnerClass("foo")).toDS(),
OuterObject.InnerClass("foo"))
}
+
+ /////////////////////////////////////////////////////////////////////////////
+ // Tests for operations migrated from DataFrame
+ /////////////////////////////////////////////////////////////////////////////
+
+ test("column selection") {
+ val df = Seq(Tuple1(1)).toDS().as("t")
+ // We should allow empty string as column name
--- End diff --
?
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] spark pull request: [SPARK-13553][SPARK-13554][SQL] Migrates basic...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/11431#issuecomment-190366817
**[Test build #52191 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/52191/consoleFull)** for PR 11431 at commit [`6cb945f`](https://github.com/apache/spark/commit/6cb945fce95ce3787391dc9b84d1be31ea3e02f9).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org