[GitHub] [spark] cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking

2019-12-03 Thread GitBox
cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] 
visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking
URL: https://github.com/apache/spark/pull/26716#discussion_r353111040
 
 

 ##
 File path: docs/sql-migration-guide.md
 ##
 @@ -254,6 +254,8 @@ license: |
 
 
 
+- Since Spark 3.0, the unary arithmetic operator plus(`+`) only accepts 
string, numeric and interval type values as inputs. Besides, `+` with a 
integral string representation will be coerced to double value, e.g. `+'1'` 
results `1.0`. In Spark version 2.4 and earlier,  there is no type checking for 
it, thus, all type values with a `+` prefix are valid, e.g. `+ array(1, 2)` is 
valid and results `[1, 2]`. Besides, there is no implicit type coercion for `+` 
with string, e.g. in Spark 2.4, the result of `+'1'` is string `1`.
 
 Review comment:
   nit: the indentation is wrong. It should be 2 spaces.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking

2019-12-03 Thread GitBox
cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] 
visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking
URL: https://github.com/apache/spark/pull/26716#discussion_r353111472
 
 

 ##
 File path: docs/sql-migration-guide.md
 ##
 @@ -254,6 +254,8 @@ license: |
 
 
 
+- Since Spark 3.0, the unary arithmetic operator plus(`+`) only accepts 
string, numeric and interval type values as inputs. Besides, `+` with a 
integral string representation will be coerced to double value, e.g. `+'1'` 
results `1.0`. In Spark version 2.4 and earlier,  there is no type checking for 
it, thus, all type values with a `+` prefix are valid, e.g. `+ array(1, 2)` is 
valid and results `[1, 2]`. Besides, there is no implicit type coercion for `+` 
with string, e.g. in Spark 2.4, the result of `+'1'` is string `1`.
 
 Review comment:
   BTW it's worth mention that, in 2.4 the unary plus operator is ignored. 
There is no type coercion at all, not only for string type.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking

2019-12-02 Thread GitBox
cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] 
visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking
URL: https://github.com/apache/spark/pull/26716#discussion_r35386
 
 

 ##
 File path: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/ExpressionParserSuite.scala
 ##
 @@ -226,10 +226,10 @@ class ExpressionParserSuite extends AnalysisTest {
   }
 
   test("unary arithmetic expressions") {
-assertEqual("+a", 'a)
+assertEqual("+a", UnaryPositive('a))
 assertEqual("-a", -'a)
 assertEqual("~a", ~'a)
-assertEqual("-+~~a", -(~(~'a)))
+assertEqual("-+~~a", -UnaryPositive(~(~'a)))
 
 Review comment:
   shall we create a shortcut '+' for `UnaryPositive` as well? The `-` is 
defined in `org.apache.spark.sql.catalyst.dsl`


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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



[GitHub] [spark] cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking

2019-12-02 Thread GitBox
cloud-fan commented on a change in pull request #26716: [SPARK-30083][SQL] 
visitArithmeticUnary should wrap PLUS case with UnaryPositive for type checking
URL: https://github.com/apache/spark/pull/26716#discussion_r352999849
 
 

 ##
 File path: docs/sql-migration-guide.md
 ##
 @@ -254,6 +254,8 @@ license: |
 
 
 
+- Since Spark 3.0, the unary arithmetic operator plus(`+`) only accepts 
string, numeric and interval type values as inputs. Besides, `+` with a 
integral string representation will be coerced to double value, e.g. `+'1'` 
results `1.0`. In Spark version 2.4 and earlier,  there is no type checking for 
it, thus, all type values with a `+` prefix are valid, e.g. `+ array(1, 2)` is 
valid and results `[1, 2]`. Besides, there is no implicit type coercion for `+` 
with string, e.g. `+'1'` results `1`.
+
 
 Review comment:
   in 2.4, `+'1'` results to string `'1'`.


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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