You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/07/26 07:35:31 UTC
[GitHub] [spark] gengliangwang opened a new pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
gengliangwang opened a new pull request #33516:
URL: https://github.com/apache/spark/pull/33516
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Add documentation for the ANSI implicit cast rules which are introduced from https://github.com/apache/spark/pull/31349
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Better documentation.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
Build and preview in local:



--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886895476
**[Test build #141649 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141649/testReport)** for PR 33516 at commit [`a2765cb`](https://github.com/apache/spark/commit/a2765cb0b0c3517da5d700a9af64f3ac6058eef6).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886482671
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141621/
--
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
[GitHub] [spark] gengliangwang commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
gengliangwang commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886454997
@srielau Thanks for summary the rules. He should be the first author on merging this PR.
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887475724
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141706/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887530688
Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46219/
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886961588
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46165/
--
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
[GitHub] [spark] cloud-fan closed pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #33516:
URL: https://github.com/apache/spark/pull/33516
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886461711
**[Test build #141621 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141621/testReport)** for PR 33516 at commit [`b06f413`](https://github.com/apache/spark/commit/b06f41364bfa066ba41db5cc20f4f9afa1b97b9e).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886954978
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46165/
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886895791
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141649/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887475423
**[Test build #141706 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141706/testReport)** for PR 33516 at commit [`fd5ecce`](https://github.com/apache/spark/commit/fd5ecce01d59781e47af3b80b49f787a0e9093cb).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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
[GitHub] [spark] SparkQA removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886884639
**[Test build #141649 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141649/testReport)** for PR 33516 at commit [`a2765cb`](https://github.com/apache/spark/commit/a2765cb0b0c3517da5d700a9af64f3ac6058eef6).
--
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
[GitHub] [spark] SparkQA removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886454462
**[Test build #141621 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141621/testReport)** for PR 33516 at commit [`b06f413`](https://github.com/apache/spark/commit/b06f41364bfa066ba41db5cc20f4f9afa1b97b9e).
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886569734
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46138/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886884639
**[Test build #141649 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141649/testReport)** for PR 33516 at commit [`a2765cb`](https://github.com/apache/spark/commit/a2765cb0b0c3517da5d700a9af64f3ac6058eef6).
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886569734
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46138/
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887475724
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141706/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887502890
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46219/
--
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
[GitHub] [spark] cloud-fan commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r677403082
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -66,11 +66,9 @@ SELECT abs(-2147483648);
+----------------+
```
-### Type Conversion
+### Cast
-Spark SQL has three kinds of type conversions: explicit casting, type coercion, and store assignment casting.
When `spark.sql.ansi.enabled` is set to `true`, explicit casting by `CAST` syntax throws a runtime exception for illegal cast patterns defined in the standard, e.g. casts from a string to an integer.
-On the other hand, `INSERT INTO` syntax throws an analysis exception when the ANSI mode enabled via `spark.sql.storeAssignmentPolicy=ANSI`.
The type conversion of Spark ANSI mode follows the syntax rules of section 6.13 "cast specification" in [ISO/IEC 9075-2:2011 Information technology — Database languages - SQL — Part 2: Foundation (SQL/Foundation)](https://www.iso.org/standard/53682.html), except it specially allows the following
Review comment:
`The type conversion` -> `Explicit cast`
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -66,11 +66,9 @@ SELECT abs(-2147483648);
+----------------+
```
-### Type Conversion
+### Cast
-Spark SQL has three kinds of type conversions: explicit casting, type coercion, and store assignment casting.
When `spark.sql.ansi.enabled` is set to `true`, explicit casting by `CAST` syntax throws a runtime exception for illegal cast patterns defined in the standard, e.g. casts from a string to an integer.
-On the other hand, `INSERT INTO` syntax throws an analysis exception when the ANSI mode enabled via `spark.sql.storeAssignmentPolicy=ANSI`.
The type conversion of Spark ANSI mode follows the syntax rules of section 6.13 "cast specification" in [ISO/IEC 9075-2:2011 Information technology — Database languages - SQL — Part 2: Foundation (SQL/Foundation)](https://www.iso.org/standard/53682.html), except it specially allows the following
Review comment:
`The type conversion` -> `The explicit cast`
--
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
[GitHub] [spark] gengliangwang commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r676771410
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
Review comment:
Done
--
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
[GitHub] [spark] gengliangwang commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r676771658
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
+| Timestamp | Timestamp |
+| String | String |
+| Binary | Binary |
+| Boolean | Boolean |
+| Interval | Interval |
+| Map | Map** |
+| Array | Array** |
+| Struct | Struct** |
+
+\* For least common type resolution float is skipped to avoid loss of precision.
+
+\*\* For a complex type, the precedence rule applies recursively to its component elements.
+
+Special rules apply for string literals and untyped NULL.
+A NULL can be promoted to any other type, while a string literal can be promoted to any simple data type.
+
+This is a graphical depiction of the precedence list as a directed tree:
+<img src="img/type-precedence-list.png" width="80%" title="Type Precedence List" alt="Type Precedence List">
+
+#### Least Common Type Resolution
+The least common type from a set of types is the narrowest type reachable from the precedence list by all elements of the set of types.
+
+The least common type resolution is used to:
+- Decide whether a function expecting a parameter of a type can be invoked using an argument of a narrower type.
+- Derive the argument type for functions which expect a shared argument type for multiple parameters, such as coalesce, least, or greatest.
Review comment:
Done(BTW the extra space will be omitted in web page anyway)
--
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
[GitHub] [spark] SparkQA removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887466540
**[Test build #141706 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141706/testReport)** for PR 33516 at commit [`fd5ecce`](https://github.com/apache/spark/commit/fd5ecce01d59781e47af3b80b49f787a0e9093cb).
--
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
[GitHub] [spark] cloud-fan commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887483184
thanks, merging to master/3.2!
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886920620
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46165/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887466540
**[Test build #141706 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141706/testReport)** for PR 33516 at commit [`fd5ecce`](https://github.com/apache/spark/commit/fd5ecce01d59781e47af3b80b49f787a0e9093cb).
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887555151
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46219/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886553418
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46138/
--
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
[GitHub] [spark] AmplabJenkins commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-887555151
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46219/
--
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
[GitHub] [spark] cloud-fan commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r677403890
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -66,11 +66,9 @@ SELECT abs(-2147483648);
+----------------+
```
-### Type Conversion
+### Cast
Review comment:
In this section, it says `In future releases, the behaviour of type coercion might change along with the other two type conversion rules.`
We should update it.
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886961588
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46165/
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886454462
**[Test build #141621 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/141621/testReport)** for PR 33516 at commit [`b06f413`](https://github.com/apache/spark/commit/b06f41364bfa066ba41db5cc20f4f9afa1b97b9e).
--
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
[GitHub] [spark] MaxGekk commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
MaxGekk commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r676646906
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
Review comment:
`Date-> Timestamp` -> `Date -> Timestamp`
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
+| Timestamp | Timestamp |
+| String | String |
+| Binary | Binary |
+| Boolean | Boolean |
+| Interval | Interval |
+| Map | Map** |
+| Array | Array** |
+| Struct | Struct** |
+
+\* For least common type resolution float is skipped to avoid loss of precision.
+
+\*\* For a complex type, the precedence rule applies recursively to its component elements.
+
+Special rules apply for string literals and untyped NULL.
+A NULL can be promoted to any other type, while a string literal can be promoted to any simple data type.
+
+This is a graphical depiction of the precedence list as a directed tree:
+<img src="img/type-precedence-list.png" width="80%" title="Type Precedence List" alt="Type Precedence List">
+
+#### Least Common Type Resolution
+The least common type from a set of types is the narrowest type reachable from the precedence list by all elements of the set of types.
+
+The least common type resolution is used to:
+- Decide whether a function expecting a parameter of a type can be invoked using an argument of a narrower type.
+- Derive the argument type for functions which expect a shared argument type for multiple parameters, such as coalesce, least, or greatest.
Review comment:
Remove a space in `argument type` -> `argument type`
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
+| Timestamp | Timestamp |
+| String | String |
+| Binary | Binary |
+| Boolean | Boolean |
+| Interval | Interval |
Review comment:
Should we distinguish year-month and day-time interval types?
--
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
[GitHub] [spark] SparkQA commented on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886516942
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46138/
--
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
[GitHub] [spark] gengliangwang commented on a change in pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
gengliangwang commented on a change in pull request #33516:
URL: https://github.com/apache/spark/pull/33516#discussion_r676772010
##########
File path: docs/sql-ref-ansi-compliance.md
##########
@@ -160,6 +160,81 @@ SELECT * FROM t;
+---+
```
+### Type coercion
+#### Type Promotion and Precedence
+When `spark.sql.ansi.enabled` is set to `true`, Spark SQL uses several rules that govern how conflicts between data types are resolved.
+At the heart of this conflict resolution is the Type Precedence List which defines whether values of a given data type can be promoted to another data type implicitly.
+
+| Data type | precedence list(from narrowest to widest) |
+|-----------|------------------------------------------------------------------|
+| Byte | Byte -> Short -> Int -> Long -> Decimal -> Float* -> Double |
+| Short | Short -> Int -> Long -> Decimal-> Float* -> Double |
+| Int | Int -> Long -> Decimal -> Float* -> Double |
+| Long | Long -> Decimal -> Float* -> Double |
+| Decimal | Decimal -> Float* -> Double |
+| Float | Float -> Double |
+| Double | Double |
+| Date | Date-> Timestamp |
+| Timestamp | Timestamp |
+| String | String |
+| Binary | Binary |
+| Boolean | Boolean |
+| Interval | Interval |
Review comment:
Let's keep it simple in this section
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886895791
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141649/
--
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
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33516: [SPARK-34249][DOCS] Add documentation for ANSI implicit cast rules
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33516:
URL: https://github.com/apache/spark/pull/33516#issuecomment-886482671
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/141621/
--
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