You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by chenghao-intel <gi...@git.apache.org> on 2015/10/13 04:42:03 UTC
[GitHub] spark pull request: [SPARK-11076][SQL]Add decimal support for floo...
GitHub user chenghao-intel opened a pull request:
https://github.com/apache/spark/pull/9086
[SPARK-11076][SQL]Add decimal support for floor and ceil
Actually all of the `UnaryMathExpression` doens't support the Decimal, will create follow ups for supporing it. This is the first PR which will be good to review the approach I am taking.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/chenghao-intel/spark ceiling
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/9086.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 #9086
----
commit 7ac537e98052e5aa0bdce8c5db6126989bb09104
Author: Cheng Hao <ha...@intel.com>
Date: 2015-10-13T02:26:58Z
Add decimal support for floor and ceil
----
---
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-11076][SQL]Add decimal support for floo...
Posted by chenghao-intel <gi...@git.apache.org>.
Github user chenghao-intel commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147624010
cc @rxin @davies
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147600005
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147999730
[Test build #43710 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43710/console) for PR 9086 at commit [`f441596`](https://github.com/apache/spark/commit/f44159641ff41a469271164d6c0b656e1497b886).
* 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-11076][SQL]Add decimal support for floo...
Posted by chenghao-intel <gi...@git.apache.org>.
Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r41943729
--- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralGenerator.scala ---
@@ -78,7 +78,17 @@ object LiteralGenerator {
Double.NaN, Double.PositiveInfinity, Double.NegativeInfinity)
} yield Literal.create(f, DoubleType)
- // TODO: decimal type
+
+ // TODO cache the generated data, and boarder the value range
+ // Since scalacheck doesn't support the decimal yet in `Choose`.
+ def decimalLiteralGen(precision: Int, scale: Int): Gen[Literal] = {
+ Gen.chooseNum(Double.MinValue, Double.MaxValue,
+ Double.NaN, Double.PositiveInfinity, Double.NegativeInfinity) map { bd =>
+ val d = Decimal(bd)
+ d.changePrecision(precision, scale)
--- End diff --
Yes, that's true, I will udpate the code by gen the random decimal according to the `precision` and `scale`.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147579391
Merged build triggered.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147579405
Merged build started.
---
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147579622
[Test build #43610 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43610/consoleFull) for PR 9086 at commit [`7ac537e`](https://github.com/apache/spark/commit/7ac537e98052e5aa0bdce8c5db6126989bb09104).
---
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-11076][SQL]Add decimal support for floo...
Posted by chenghao-intel <gi...@git.apache.org>.
Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r42071708
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ---
@@ -153,13 +153,29 @@ case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN"
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL") {
- override def dataType: DataType = LongType
- protected override def nullSafeEval(input: Any): Any = {
- f(input.asInstanceOf[Double]).toLong
+ override def dataType: DataType = child.dataType match {
+ case dt @ DecimalType.Fixed(_, 0) => dt
+ case DecimalType.Fixed(precision, scale) =>
+ DecimalType.bounded(precision - scale + 1, 0)
+ case _ => LongType
+ }
+
+ override def inputTypes: Seq[AbstractDataType] =
+ Seq(TypeCollection(DoubleType, FloatType, DecimalType))
--- End diff --
This was actually for performance concern, we don't want to make extra casting from `Float` -> `Double`; After double checking the function `math.ceil`, seems it only support the `double` type. I will update the code.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147600007
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43610/
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148000258
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-11076][SQL]Add decimal support for floo...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/spark/pull/9086
---
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148245728
[Test build #43760 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43760/consoleFull) for PR 9086 at commit [`156372f`](https://github.com/apache/spark/commit/156372f038db009c7f70d305a2770abbf68e0908).
---
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-11076][SQL]Add decimal support for floo...
Posted by chenghao-intel <gi...@git.apache.org>.
Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r41963802
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ---
@@ -153,13 +153,26 @@ case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN"
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL") {
- override def dataType: DataType = LongType
- protected override def nullSafeEval(input: Any): Any = {
- f(input.asInstanceOf[Double]).toLong
+ override def dataType: DataType = child.dataType match {
+ case DecimalType.Fixed(precision, scale) => DecimalType(precision, 0)
--- End diff --
Good catch! After checking with Hive, seems it should be `DecimalType(precision - scale + 1, 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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r42020484
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ---
@@ -153,13 +153,29 @@ case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN"
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL") {
- override def dataType: DataType = LongType
- protected override def nullSafeEval(input: Any): Any = {
- f(input.asInstanceOf[Double]).toLong
+ override def dataType: DataType = child.dataType match {
+ case dt @ DecimalType.Fixed(_, 0) => dt
+ case DecimalType.Fixed(precision, scale) =>
+ DecimalType.bounded(precision - scale + 1, 0)
+ case _ => LongType
+ }
+
+ override def inputTypes: Seq[AbstractDataType] =
+ Seq(TypeCollection(DoubleType, FloatType, DecimalType))
--- End diff --
FloatType will be casted to DoubleType, we don't need it 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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148000260
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43710/
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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r41908052
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala ---
@@ -153,13 +153,26 @@ case class Atan(child: Expression) extends UnaryMathExpression(math.atan, "ATAN"
case class Cbrt(child: Expression) extends UnaryMathExpression(math.cbrt, "CBRT")
case class Ceil(child: Expression) extends UnaryMathExpression(math.ceil, "CEIL") {
- override def dataType: DataType = LongType
- protected override def nullSafeEval(input: Any): Any = {
- f(input.asInstanceOf[Double]).toLong
+ override def dataType: DataType = child.dataType match {
+ case DecimalType.Fixed(precision, scale) => DecimalType(precision, 0)
--- End diff --
Shout the result be `DecimalType(precision-scale, 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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147965851
Merged build started.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148270768
Test PASSed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43760/
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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r42020733
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala ---
@@ -309,10 +319,24 @@ final class Decimal extends Ordered[Decimal] with Serializable {
}
def abs: Decimal = if (this.compare(Decimal.ZERO) < 0) this.unary_- else this
+
+ def floor: Decimal = if (scale == 0) this else {
+ val value = this.clone()
+ value.changePrecision(precision, 0, ROUND_FLOOR)
--- End diff --
The new precision should be `precision - scale + 1`
---
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147967199
[Test build #43710 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43710/consoleFull) for PR 9086 at commit [`f441596`](https://github.com/apache/spark/commit/f44159641ff41a469271164d6c0b656e1497b886).
---
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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r41908592
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala ---
@@ -198,6 +198,16 @@ final class Decimal extends Ordered[Decimal] with Serializable {
* @return true if successful, false if overflow would occur
*/
def changePrecision(precision: Int, scale: Int): Boolean = {
+ changePrecision(precision, scale, ROUND_HALF_UP)
+ }
+
+ /**
+ * Update precision and scale while keeping our value the same, and return true if successful.
+ *
+ * @return true if successful, false if overflow would occur
+ */
+ def changePrecision(precision: Int, scale: Int,
--- End diff --
private
---
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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148245945
LGTM
---
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148270700
[Test build #43760 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43760/console) for PR 9086 at commit [`156372f`](https://github.com/apache/spark/commit/156372f038db009c7f70d305a2770abbf68e0908).
* 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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148243944
Merged build triggered.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148243962
Merged build started.
---
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-11076][SQL]Add decimal support for floo...
Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148286628
btw the cost to cast from float to double or double to float is next to nothing, compared with other operations.
---
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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-148270767
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-11076][SQL]Add decimal support for floo...
Posted by davies <gi...@git.apache.org>.
Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r41908361
--- Diff: sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/LiteralGenerator.scala ---
@@ -78,7 +78,17 @@ object LiteralGenerator {
Double.NaN, Double.PositiveInfinity, Double.NegativeInfinity)
} yield Literal.create(f, DoubleType)
- // TODO: decimal type
+
+ // TODO cache the generated data, and boarder the value range
+ // Since scalacheck doesn't support the decimal yet in `Choose`.
+ def decimalLiteralGen(precision: Int, scale: Int): Gen[Literal] = {
+ Gen.chooseNum(Double.MinValue, Double.MaxValue,
+ Double.NaN, Double.PositiveInfinity, Double.NegativeInfinity) map { bd =>
+ val d = Decimal(bd)
+ d.changePrecision(precision, scale)
--- End diff --
The resulting decimal could be null (out of range)
---
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-11076][SQL]Add decimal support for floo...
Posted by chenghao-intel <gi...@git.apache.org>.
Github user chenghao-intel commented on a diff in the pull request:
https://github.com/apache/spark/pull/9086#discussion_r42071415
--- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/types/Decimal.scala ---
@@ -309,10 +319,24 @@ final class Decimal extends Ordered[Decimal] with Serializable {
}
def abs: Decimal = if (this.compare(Decimal.ZERO) < 0) this.unary_- else this
+
+ def floor: Decimal = if (scale == 0) this else {
+ val value = this.clone()
+ value.changePrecision(precision, 0, ROUND_FLOOR)
--- End diff --
Oh, yes, forgot to change this line.
---
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-11076][SQL]Add decimal support for floo...
Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147599906
[Test build #43610 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/43610/console) for PR 9086 at commit [`7ac537e`](https://github.com/apache/spark/commit/7ac537e98052e5aa0bdce8c5db6126989bb09104).
* 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-11076][SQL]Add decimal support for floo...
Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:
https://github.com/apache/spark/pull/9086#issuecomment-147965829
Merged build triggered.
---
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