You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "nchammas (via GitHub)" <gi...@apache.org> on 2024/02/02 17:33:13 UTC

[PR] [MINOR][DOCS] Explain that the default fractional numeric literal is a decimal [spark]

nchammas opened a new pull request, #45003:
URL: https://github.com/apache/spark/pull/45003

   ### What changes were proposed in this pull request?
   
   Explain that a number like `123.456`, without a postfix but with a decimal point, is a decimal literal.
   
   ### Why are the changes needed?
   
   In Python (and I think Java too) fractional numeric literals are typically floats. To get decimals, you need to provide an explicit postfix or use an explicit class.
   
   In Spark, it's the other way around. I found this surprising and couldn't find documentation about it.
   
   I discovered this after reading SPARK-45786. I did a little searching and came across #10796, which shows that we used to default to floats as the fractional numeric literal, but then switched to decimals.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, it adds a bit of documentation.
   
   ### How was this patch tested?
   
   No testing.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   No.


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "nchammas (via GitHub)" <gi...@apache.org>.
nchammas commented on code in PR #45003:
URL: https://github.com/apache/spark/pull/45003#discussion_r1477728902


##########
docs/sql-ref-literals.md:
##########
@@ -275,6 +275,10 @@ E [ + | - ] digit [ ... ]
 
     Case insensitive, indicates `DECIMAL`, with the total number of digits as precision and the number of digits to right of decimal point as scale.
 
+* **default (no postfix)**
+
+    Indicates `DECIMAL`, same as the `BD` postfix.

Review Comment:
   Ah, ok. I can make another PR to clarify this point, unless you prefer to do it yourself.



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon closed pull request #45003: [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal
URL: https://github.com/apache/spark/pull/45003


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on PR #45003:
URL: https://github.com/apache/spark/pull/45003#issuecomment-1926281889

   Merged to master.


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "yaooqinn (via GitHub)" <gi...@apache.org>.
yaooqinn commented on code in PR #45003:
URL: https://github.com/apache/spark/pull/45003#discussion_r1477728004


##########
docs/sql-ref-literals.md:
##########
@@ -275,6 +275,10 @@ E [ + | - ] digit [ ... ]
 
     Case insensitive, indicates `DECIMAL`, with the total number of digits as precision and the number of digits to right of decimal point as scale.
 
+* **default (no postfix)**
+
+    Indicates `DECIMAL`, same as the `BD` postfix.

Review Comment:
   exponential w/o postfix, such as 1.2E3, is a double by default



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "nchammas (via GitHub)" <gi...@apache.org>.
nchammas commented on code in PR #45003:
URL: https://github.com/apache/spark/pull/45003#discussion_r1477736202


##########
docs/sql-ref-literals.md:
##########
@@ -275,6 +275,10 @@ E [ + | - ] digit [ ... ]
 
     Case insensitive, indicates `DECIMAL`, with the total number of digits as precision and the number of digits to right of decimal point as scale.
 
+* **default (no postfix)**
+
+    Indicates `DECIMAL`, same as the `BD` postfix.

Review Comment:
   Sure, if you prefer to do that. I will make a new PR to clarify the default type with and without the exponent.



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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


Re: [PR] [MINOR][DOCS] The default fractional numeric literal in SQL is a decimal [spark]

Posted by "HyukjinKwon (via GitHub)" <gi...@apache.org>.
HyukjinKwon commented on code in PR #45003:
URL: https://github.com/apache/spark/pull/45003#discussion_r1477735229


##########
docs/sql-ref-literals.md:
##########
@@ -275,6 +275,10 @@ E [ + | - ] digit [ ... ]
 
     Case insensitive, indicates `DECIMAL`, with the total number of digits as precision and the number of digits to right of decimal point as scale.
 
+* **default (no postfix)**
+
+    Indicates `DECIMAL`, same as the `BD` postfix.

Review Comment:
   Ohh actually let me revert this first. Let's make the proper fix together.



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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


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