-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-31753][SQL][DOCS] Add missing keywords in the SQL docs #29056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
bb1efa2
Merge pull request #1 from apache/master
GuoPhilipse 1459d5b
Merge pull request #2 from apache/master
GuoPhilipse 88c40fe
Merge pull request #3 from apache/master
GuoPhilipse df22083
Merge pull request #4 from apache/master
GuoPhilipse 0436611
Merge pull request #5 from apache/master
GuoPhilipse ed80c84
Merge pull request #6 from apache/master
GuoPhilipse 39ca87c
Merge pull request #7 from apache/master
GuoPhilipse c3b3c89
Merge pull request #8 from apache/master
GuoPhilipse c3546eb
Merge pull request #9 from apache/master
GuoPhilipse 77a339a
Merge pull request #10 from apache/master
GuoPhilipse a6b4f74
Merge pull request #11 from apache/master
GuoPhilipse 664277e
Merge pull request #12 from apache/master
GuoPhilipse fd677c9
Merge pull request #13 from apache/master
GuoPhilipse 93b1f63
Merge pull request #14 from apache/master
GuoPhilipse a5b5474
Merge pull request #15 from apache/master
GuoPhilipse f4556a4
Merge pull request #16 from apache/master
GuoPhilipse 6071006
Merge pull request #17 from apache/master
GuoPhilipse 596b842
Merge pull request #18 from apache/master
GuoPhilipse dc24541
Merge pull request #19 from apache/master
GuoPhilipse c6f541b
Merge pull request #20 from apache/master
GuoPhilipse a80fa85
update case when docs
GuoPhilipse e4c2a17
update case when docs
GuoPhilipse 24b64a8
update case when docs
GuoPhilipse 3b15c75
fix capital issue.etc
GuoPhilipse 0d9e72d
improve syntax desc
GuoPhilipse a119c85
add missing key words
GuoPhilipse 61c57d1
fix spell error
GuoPhilipse b3a3248
update pivot and lateral view key words
GuoPhilipse 2ee5419
update lateral view usgae
GuoPhilipse 95071f3
update docs
GuoPhilipse bbce7d0
trigger rebuild
GuoPhilipse 15aae2b
trigger rebuild
GuoPhilipse 0625ca8
remove spark version
GuoPhilipse 03da596
update docs
GuoPhilipse 5b562eb
update docs
GuoPhilipse 1570d76
update docs
GuoPhilipse d72139e
update docs
GuoPhilipse 21ebafc
update docs
GuoPhilipse e5a1cf1
update docs
GuoPhilipse b281494
update docs
GuoPhilipse bed618b
update docs\
GuoPhilipse caa7130
update docs
GuoPhilipse 2813735
update docs
GuoPhilipse ffa0603
update docs
GuoPhilipse File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| --- | ||
| layout: global | ||
| title: CASE Clause | ||
| displayTitle: CASE Clause | ||
| license: | | ||
| Licensed to the Apache Software Foundation (ASF) under one or more | ||
| contributor license agreements. See the NOTICE file distributed with | ||
| this work for additional information regarding copyright ownership. | ||
| The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| (the "License"); you may not use this file except in compliance with | ||
| the License. You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| --- | ||
|
|
||
| ### Description | ||
|
|
||
| `CASE` clause uses a rule to return a specific result based on the specified condition, similar to if/else statements in other programming languages. | ||
|
|
||
| ### Syntax | ||
|
|
||
| ```sql | ||
| CASE [ expression ] { WHEN boolean_expression THEN then_expression } [ ... ] | ||
| [ ELSE else_expression ] | ||
| END | ||
| ``` | ||
huaxingao marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ### Parameters | ||
|
|
||
| * **boolean_expression** | ||
|
|
||
| Specifies any expression that evaluates to a result type `boolean`. Two or | ||
| more expressions may be combined together using the logical | ||
| operators ( `AND`, `OR` ). | ||
|
|
||
| * **then_expression** | ||
|
|
||
| Specifies the then expression based on the `boolean_expression` condition; `then_expression` and `else_expression` should all be same type or coercible to a common type. | ||
|
|
||
| * **else_expression** | ||
|
|
||
| Specifies the default expression; `then_expression` and `else_expression` should all be same type or coercible to a common type. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```sql | ||
| CREATE TABLE person (id INT, name STRING, age INT); | ||
| INSERT INTO person VALUES | ||
| (100, 'John', 30), | ||
| (200, 'Mary', NULL), | ||
| (300, 'Mike', 80), | ||
| (400, 'Dan', 50); | ||
|
|
||
| SELECT id, CASE WHEN id > 200 THEN 'bigger' ELSE 'small' END FROM person; | ||
| +------+--------------------------------------------------+ | ||
| | id | CASE WHEN (id > 200) THEN bigger ELSE small END | | ||
| +------+--------------------------------------------------+ | ||
| | 100 | small | | ||
| | 200 | small | | ||
| | 300 | bigger | | ||
| | 400 | bigger | | ||
| +------+--------------------------------------------------+ | ||
|
|
||
| SELECT id, CASE id WHEN 100 then 'bigger' WHEN id > 300 THEN '300' ELSE 'small' END FROM person; | ||
| +------+-----------------------------------------------------------------------------------------------+ | ||
| | id | CASE WHEN (id = 100) THEN bigger WHEN (id = CAST((id > 300) AS INT)) THEN 300 ELSE small END | | ||
| +------+-----------------------------------------------------------------------------------------------+ | ||
| | 100 | bigger | | ||
| | 200 | small | | ||
| | 300 | small | | ||
| | 400 | small | | ||
| +------+-----------------------------------------------------------------------------------------------+ | ||
|
|
||
| SELECT * FROM person | ||
| WHERE | ||
| CASE 1 = 1 | ||
| WHEN 100 THEN 'big' | ||
| WHEN 200 THEN 'bigger' | ||
| WHEN 300 THEN 'biggest' | ||
| ELSE 'small' | ||
| END = 'small'; | ||
| +------+-------+-------+ | ||
| | id | name | age | | ||
| +------+-------+-------+ | ||
| | 100 | John | 30 | | ||
| | 200 | Mary | NULL | | ||
| | 300 | Mike | 80 | | ||
| | 400 | Dan | 50 | | ||
| +------+-------+-------+ | ||
| ``` | ||
|
|
||
| ### Related Statements | ||
|
|
||
| * [SELECT Main](sql-ref-syntax-qry-select.html) | ||
| * [WHERE Clause](sql-ref-syntax-qry-select-where.html) | ||
| * [GROUP BY Clause](sql-ref-syntax-qry-select-groupby.html) | ||
| * [HAVING Clause](sql-ref-syntax-qry-select-having.html) | ||
| * [ORDER BY Clause](sql-ref-syntax-qry-select-orderby.html) | ||
| * [SORT BY Clause](sql-ref-syntax-qry-select-sortby.html) | ||
| * [DISTRIBUTE BY Clause](sql-ref-syntax-qry-select-distribute-by.html) | ||
| * [LIMIT Clause](sql-ref-syntax-qry-select-limit.html) | ||
| * [PIVOT Clause](sql-ref-syntax-qry-select-pivot.html) | ||
| * [LATERAL VIEW Clause](sql-ref-syntax-qry-select-lateral-view.html) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bucketSpec is still missing in CREATE HIVE FORMAT table, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason we did not add it? @huaxingao @GuoPhilipse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, we missed that.
@GuoPhilipse Could you please have a follow-up to add
bucketSpec? Thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need it, will add it soon.