maropu commented on a change in pull request #28151: [SPARK-31383][SQL][DOC]
Clean up the SQL documents in docs/sql-ref*
URL: https://github.com/apache/spark/pull/28151#discussion_r405986241
##########
File path: docs/sql-ref-syntax-ddl-alter-table.md
##########
@@ -263,223 +277,219 @@ ALTER TABLE table_identifier [ partition_spec ] SET
LOCATION 'new_location'
<dd>Specifies the SERDE properties to be set.</dd>
</dl>
-
### Examples
-{% highlight sql %}
---RENAME table
+{% highlight sql %}
+-- RENAME table
DESC student;
-+--------------------------+------------+----------+--+
-| col_name | data_type | comment |
-+--------------------------+------------+----------+--+
-| name | string | NULL |
-| rollno | int | NULL |
-| age | int | NULL |
-| # Partition Information | | |
-| # col_name | data_type | comment |
-| age | int | NULL |
-+--------------------------+------------+----------+--+
+ +-----------------------+---------+-------+
+ | col_name|data_type|comment|
+ +-----------------------+---------+-------+
+ | name| string| NULL|
+ | rollno| int| NULL|
+ | age| int| NULL|
+ |# Partition Information| | |
+ | # col_name|data_type|comment|
+ | age| int| NULL|
+ +-----------------------+---------+-------+
ALTER TABLE Student RENAME TO StudentInfo;
---After Renaming the table
+-- After Renaming the table
DESC StudentInfo;
-+--------------------------+------------+----------+--+
-| col_name | data_type | comment |
-+--------------------------+------------+----------+--+
-| name | string | NULL |
-| rollno | int | NULL |
-| age | int | NULL |
-| # Partition Information | | |
-| # col_name | data_type | comment |
-| age | int | NULL |
-+--------------------------+------------+----------+--+
-
---RENAME partition
+ +-----------------------+---------+-------+
+ | col_name|data_type|comment|
+ +-----------------------+---------+-------+
+ | name| string| NULL|
+ | rollno| int| NULL|
+ | age| int| NULL|
+ |# Partition Information| | |
+ | # col_name|data_type|comment|
+ | age| int| NULL|
+ +-----------------------+---------+-------+
+
+-- RENAME partition
SHOW PARTITIONS StudentInfo;
-+------------+--+
-| partition |
-+------------+--+
-| age=10 |
-| age=11 |
-| age=12 |
-+------------+--+
+ +---------+
+ |partition|
+ +---------+
+ | age=10|
+ | age=11|
+ | age=12|
+ +---------+
ALTER TABLE default.StudentInfo PARTITION (age='10') RENAME TO PARTITION
(age='15');
---After renaming Partition
+-- After renaming Partition
SHOW PARTITIONS StudentInfo;
-+------------+--+
-| partition |
-+------------+--+
-| age=11 |
-| age=12 |
-| age=15 |
-+------------+--+
+ +---------+
+ |partition|
+ +---------+
+ | age=11|
+ | age=12|
+ | age=15|
+ +---------+
-- Add new columns to a table
DESC StudentInfo;
-+--------------------------+------------+----------+--+
-| col_name | data_type | comment |
-+--------------------------+------------+----------+--+
-| name | string | NULL |
-| rollno | int | NULL |
-| age | int | NULL |
-| # Partition Information | | |
-| # col_name | data_type | comment |
-| age | int | NULL |
-+--------------------------+------------+----------+
+ +-----------------------+---------+-------+
+ | col_name|data_type|comment|
+ +-----------------------+---------+-------+
+ | name| string| NULL|
+ | rollno| int| NULL|
+ | age| int| NULL|
+ |# Partition Information| | |
+ | # col_name|data_type|comment|
+ | age| int| NULL|
+ +-----------------------+---------+-------+
ALTER TABLE StudentInfo ADD columns (LastName string, DOB timestamp);
---After Adding New columns to the table
+-- After Adding New columns to the table
DESC StudentInfo;
-+--------------------------+------------+----------+--+
-| col_name | data_type | comment |
-+--------------------------+------------+----------+--+
-| name | string | NULL |
-| rollno | int | NULL |
-| LastName | string | NULL |
-| DOB | timestamp | NULL |
-| age | int | NULL |
-| # Partition Information | | |
-| # col_name | data_type | comment |
-| age | int | NULL |
-+--------------------------+------------+----------+--+
+ +-----------------------+---------+-------+
+ | col_name|data_type|comment|
+ +-----------------------+---------+-------+
+ | name| string| NULL|
+ | rollno| int| NULL|
+ | LastName| string| NULL|
+ | DOB|timestamp| NULL|
+ | age| int| NULL|
+ |# Partition Information| | |
+ | # col_name|data_type|comment|
+ | age| int| NULL|
+ +-----------------------+---------+-------+
-- Add a new partition to a table
SHOW PARTITIONS StudentInfo;
-+------------+--+
-| partition |
-+------------+--+
-| age=11 |
-| age=12 |
-| age=15 |
-+------------+--+
+ +---------+
+ |partition|
+ +---------+
+ | age=11|
+ | age=12|
+ | age=15|
+ +---------+
ALTER TABLE StudentInfo ADD IF NOT EXISTS PARTITION (age=18);
-- After adding a new partition to the table
Review comment:
yea, you're right. I'll remove that. thanks.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]