You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by wangyum <gi...@git.apache.org> on 2017/05/31 03:45:21 UTC

[GitHub] spark pull request #18153: [SPARK-20931][SQL] ABS function support string ty...

GitHub user wangyum opened a pull request:

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

    [SPARK-20931][SQL] ABS function support string type.

    ## What changes were proposed in this pull request?
    
    ABS function support string type. Hive/MySQL support this feature.
    
    Ref: https://github.com/apache/hive/blob/4ba713ccd85c3706d195aeef9476e6e6363f1c21/ql/src/java/org/apache/hadoop/hive/ql/udf/generic/GenericUDFAbs.java#L93
    
    ## How was this patch tested?
     unit tests

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

    $ git pull https://github.com/wangyum/spark SPARK-20931

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

    https://github.com/apache/spark/pull/18153.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 #18153
    
----
commit 209dbaf07ed93bdd66d89b0bc45ebdd898632e27
Author: Yuming Wang <wg...@gmail.com>
Date:   2017-05-31T03:40:19Z

    ABS function support string 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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #77583 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77583/testReport)** for PR 18153 at commit [`1b70f29`](https://github.com/apache/spark/commit/1b70f299ea19c6efb1f4d69c3b3459c8bbb5fb94).


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #78170 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78170/testReport)** for PR 18153 at commit [`afdb40d`](https://github.com/apache/spark/commit/afdb40ddd39acbc2b11a0db1810e9f77b43f8240).
     * This patch **fails Spark unit 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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r119527989
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    I would like to hear @gatorsmile 's opinion. Which specification should Spark support?


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r119269154
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    How should it work when a given string includes non-numerical character?
    e.g. https://zohoreportsapi.wiki.zoho.com/MySQL-Math-Functions.html


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/78170/
    Test FAILed.


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #77576 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77576/testReport)** for PR 18153 at commit [`1b70f29`](https://github.com/apache/spark/commit/1b70f299ea19c6efb1f4d69c3b3459c8bbb5fb94).


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by wangyum <gi...@git.apache.org>.
Github user wangyum commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r119340217
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    MySQL support it, do we need to support this feature?


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Thanks! Merging to master.


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #78182 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78182/testReport)** for PR 18153 at commit [`8405784`](https://github.com/apache/spark/commit/8405784e8980ab052273184035f523c0030e5d6c).


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #77583 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77583/testReport)** for PR 18153 at commit [`1b70f29`](https://github.com/apache/spark/commit/1b70f299ea19c6efb1f4d69c3b3459c8bbb5fb94).
     * 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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #78182 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78182/testReport)** for PR 18153 at commit [`8405784`](https://github.com/apache/spark/commit/8405784e8980ab052273184035f523c0030e5d6c).
     * 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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Merged build finished. Test FAILed.


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by kiszk <gi...@git.apache.org>.
Github user kiszk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r119332964
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    How about MySQL?


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/77583/
    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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Merged build finished. Test FAILed.


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/78182/
    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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r122371858
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    --- End diff --
    
    Could we move the type promotion to the rule [PromoteStrings](https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala#L360-L367)?


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #78170 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/78170/testReport)** for PR 18153 at commit [`afdb40d`](https://github.com/apache/spark/commit/afdb40ddd39acbc2b11a0db1810e9f77b43f8240).


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/77571/
    Test FAILed.


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by wangyum <gi...@git.apache.org>.
Github user wangyum commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r119271567
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    `NumberFormatException` will throw, Hive does not support non-numerical character also.


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #77571 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77571/testReport)** for PR 18153 at commit [`209dbaf`](https://github.com/apache/spark/commit/209dbaf07ed93bdd66d89b0bc45ebdd898632e27).


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    **[Test build #77571 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/77571/testReport)** for PR 18153 at commit [`209dbaf`](https://github.com/apache/spark/commit/209dbaf07ed93bdd66d89b0bc45ebdd898632e27).
     * This patch **fails Spark unit 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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    LGTM pending Jenkins. 


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Merged build finished. Test FAILed.


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

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


---
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 #18153: [SPARK-20931][SQL] ABS function support string ty...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18153#discussion_r122371706
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/arithmetic.scala ---
    @@ -97,20 +97,30 @@ case class UnaryPositive(child: Expression)
     case class Abs(child: Expression)
         extends UnaryExpression with ExpectsInputTypes with NullIntolerant {
     
    -  override def inputTypes: Seq[AbstractDataType] = Seq(NumericType)
    +  override def inputTypes: Seq[AbstractDataType] = Seq(TypeCollection(NumericType, StringType))
     
    -  override def dataType: DataType = child.dataType
    +  override def dataType: DataType = child.dataType match {
    +    case dt: NumericType => dt
    +    case dt: StringType => DoubleType
    +  }
     
       private lazy val numeric = TypeUtils.getNumeric(dataType)
     
    -  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = dataType match {
    +  override def doGenCode(ctx: CodegenContext, ev: ExprCode): ExprCode = child.dataType match {
         case dt: DecimalType =>
           defineCodeGen(ctx, ev, c => s"$c.abs()")
         case dt: NumericType =>
           defineCodeGen(ctx, ev, c => s"(${ctx.javaType(dt)})(java.lang.Math.abs($c))")
    +    case dt: StringType =>
    +      defineCodeGen(ctx, ev, c => s"java.lang.Math.abs(Double.valueOf($c.toString()))")
    --- End diff --
    
    Thanks for ping me. To be consistent with the other mathematic expressions in Spark SQL, let us just convert it to Double.


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by wangyum <gi...@git.apache.org>.
Github user wangyum commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Jenkins, retest this please


---
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 issue #18153: [SPARK-20931][SQL] ABS function support string type.

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/18153
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/77576/
    Test FAILed.


---
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