[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*#28151
[SPARK-31383][SQL][DOC] Clean up the SQL documents in docs/sql-ref*#28151maropu wants to merge 3 commits into
Conversation
|
@gatorsmile @huaxingao @kevinyu98 @srowen I've roughly checked the current whole SQL docs and fixed minor&trivial issues for consistency across the docs. How about this update? |
|
Test build #120959 has finished for PR 28151 at commit
|
srowen
left a comment
There was a problem hiding this comment.
If it's just cleanup, fine. This is for 3.0?
I skimmed the changes and it looks indeed like just formatting, etc.
| |Fred|50 | | ||
| |Dan |50 | | ||
| |Fred| 50| | ||
| | Da | 50| |
| | col_name| data_type|comment| | ||
| +--------------------+--------------------+-------+ | ||
| | name| string| null| | ||
| | student_id| int| null| |
There was a problem hiding this comment.
null -> NULL?
Shall we change all the null to NULL in tables?
There was a problem hiding this comment.
Ur, null looks ok because Dataset.showString does so;
scala> Seq(Some(1), None).toDF("a").show()
+----+
| a|
+----+
| 1|
|null|
+----+
There was a problem hiding this comment.
These are SQL examples. SQL uses NULL?
There was a problem hiding this comment.
I'm not faimilar with that though, the output format looks implementation-specific. For example, PostgreSQL uses an empty cell for null by default. Anyway, I like the simple document rule like Query output in Examples should follow the Dataset.showString (right-aligned) format. Since we can easily replace it later, I leave it as it is in this PR. If necessary, please do follow-up later.
| |name|rollno|age| | ||
| +----+------+---+ | ||
| +----+------+---+ | ||
| No rows selected |
There was a problem hiding this comment.
nit: This line is a comment, right? put -- in front of it?
There was a problem hiding this comment.
Ah, yes. Probably, we can remove this. Thanks!
|
@maropu Thanks a lot for doing this! |
|
This is for 3.0. @srowen |
|
Yea, this is just a clean-up for 3.0. |
|
|
||
| #### Examples | ||
|
|
||
| {% highlight sql %} |
There was a problem hiding this comment.
@huaxingao I moved the examples into the seb-sections of EXCEPT/INTERSECT/UNION for readability. Could you check this?
|
@huaxingao @kevinyu98 If no problem, could you apply the same cleanup for your open PRs at your convenience? |
|
Test build #120988 has finished for PR 28151 at commit
|
|
I will reformat my open PRs. |
| |-- name: string (nullable = true) | ||
| |-- grade: integer (nullable = true) | ||
| +--------+---------+-----------+--------------------------------------------------------------+ |
There was a problem hiding this comment.
does this output need to be right-aligned? also the following SHOW TABLE output.
There was a problem hiding this comment.
Yea right, but the information cell itself assumes to be left-aligned, so I left it as it is. Probably, this is an exception case.
|
|
||
| ALTER TABLE StudentInfo ADD IF NOT EXISTS PARTITION (age=18); | ||
|
|
||
| -- After adding a new partition to the table |
There was a problem hiding this comment.
Do we need to leave space after --? I saw some have one space, some didn't have.
There was a problem hiding this comment.
yea, you're right. I'll remove that. thanks.
|
Test build #121008 has finished for PR 28151 at commit
|
|
retest this please |
|
Test build #121012 has finished for PR 28151 at commit
|
| --Default Output | ||
| {% highlight sql %} | ||
| -- Default Output | ||
|
|
There was a problem hiding this comment.
do we need leave space here? also the following -- in this file.
5f6677a to
945b28c
Compare
|
Test build #121058 has finished for PR 28151 at commit
|
|
@srowen Could you check? |
|
LGTM |
945b28c to
658fc77
Compare
|
Test build #121156 has finished for PR 28151 at commit
|
|
Test build #121158 has finished for PR 28151 at commit
|
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes #28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
(cherry picked from commit 179289f)
Signed-off-by: Sean Owen <srowen@gmail.com>
|
Merged to master/3.0 |
### What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in `doc/sql-ref*`.
Main changes are as follows;
- Fixes wrong syntaxes and capitalize sub-titles
- Adds some DDL queries in `Examples` so that users can run examples there
- Makes query output in `Examples` follows the `Dataset.showString` (right-aligned) format
- Adds/Removes spaces, Indents, or blank lines to follow the format below;
```
---
license...
---
### Description
Writes what's the syntax is.
### Syntax
{% highlight sql %}
SELECT...
WHERE... // 4 indents after the second line
...
{% endhighlight %}
### Parameters
<dl>
<dt><code><em>Param Name</em></code></dt>
<dd>
Param Description
</dd>
...
</dl>
### Examples
{% highlight sql %}
-- It is better that users are able to execute example queries here.
-- So, we prepare test data in the first section if possible.
CREATE TABLE t (key STRING, value DOUBLE);
INSERT INTO t VALUES
('a', 1.0), ('a', 2.0), ('b', 3.0), ('c', 4.0);
-- query output has 2 indents and it follows the `Dataset.showString`
-- format (right-aligned).
SELECT * FROM t;
+---+-----+
|key|value|
+---+-----+
| a| 1.0|
| a| 2.0|
| b| 3.0|
| c| 4.0|
+---+-----+
-- Query statements after the second line have 4 indents.
SELECT key, SUM(value)
FROM t
GROUP BY key;
+---+----------+
|key|sum(value)|
+---+----------+
| c| 4.0|
| b| 3.0|
| a| 3.0|
+---+----------+
...
{% endhighlight %}
### Related Statements
* [XXX](xxx.html)
* ...
```
### Why are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
### Does this PR introduce any user-facing change?
Yes.
### How was this patch tested?
Manually checked.
Closes apache#28151 from maropu/MakeRightAligned.
Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Sean Owen <srowen@gmail.com>
… for MsSqlServerDialect ## What changes were proposed in this pull request? This PR aims to correct mappings in `MsSqlServerDialect`. `ShortType` is mapped to `SMALLINT` and `FloatType` is mapped to `REAL` per [JBDC mapping]( https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-2017) respectively. ShortType and FloatTypes are not correctly mapped to right JDBC types when using JDBC connector. This results in tables and spark data frame being created with unintended types. The issue was observed when validating against SQLServer. Refer [JBDC mapping]( https://docs.microsoft.com/en-us/sql/connect/jdbc/using-basic-data-types?view=sql-server-2017 ) for guidance on mappings between SQLServer, JDBC and Java. Note that java "Short" type should be mapped to JDBC "SMALLINT" and java Float should be mapped to JDBC "REAL". Some example issue that can happen because of wrong mappings - Write from df with column type results in a SQL table of with column type as INTEGER as opposed to SMALLINT.Thus a larger table that expected. - Read results in a dataframe with type INTEGER as opposed to ShortType - ShortType has a problem in both the the write and read path - FloatTypes only have an issue with read path. In the write path Spark data type 'FloatType' is correctly mapped to JDBC equivalent data type 'Real'. But in the read path when JDBC data types need to be converted to Catalyst data types ( getCatalystType) 'Real' gets incorrectly gets mapped to 'DoubleType' rather than 'FloatType'. Refer apache#28151 which contained this fix as one part of a larger PR. Following PR apache#28151 discussion it was decided to file seperate PRs for each of the fixes. ## How was this patch tested? UnitTest added in JDBCSuite.scala and these were tested. Integration test updated and passed in MsSqlServerDialect.scala E2E test done with SQLServer Closes apache#25146 from shivsood/float_short_type_fix. Authored-by: shivsood <shivsood@microsoft.com> Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
What changes were proposed in this pull request?
This PR intends to clean up the SQL documents in
doc/sql-ref*.Main changes are as follows;
Examplesso that users can run examples thereExamplesfollows theDataset.showString(right-aligned) formatWhy are the changes needed?
The most changes of this PR are pretty minor, but I think the consistent formats/rules to write documents are important for long-term maintenance in our community
Does this PR introduce any user-facing change?
Yes.
How was this patch tested?
Manually checked.