diff --git a/docs/sql-ref-syntax-aux-describe-database.md b/docs/sql-ref-syntax-aux-describe-database.md index 2f7b1ce984d3..590438b3cf71 100644 --- a/docs/sql-ref-syntax-aux-describe-database.md +++ b/docs/sql-ref-syntax-aux-describe-database.md @@ -42,7 +42,7 @@ interchangeable. -### Example +### Examples {% highlight sql %} -- Create employees DATABASE diff --git a/docs/sql-ref-syntax-aux-show-tables.md b/docs/sql-ref-syntax-aux-show-tables.md index 0b7062ec8eff..0617e94b2acd 100644 --- a/docs/sql-ref-syntax-aux-show-tables.md +++ b/docs/sql-ref-syntax-aux-show-tables.md @@ -52,7 +52,7 @@ SHOW TABLES [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ] -### Example +### Examples {% highlight sql %} -- List all tables in default database diff --git a/docs/sql-ref-syntax-aux-show-views.md b/docs/sql-ref-syntax-aux-show-views.md index aec3716c2889..ece7e1c5b89d 100644 --- a/docs/sql-ref-syntax-aux-show-views.md +++ b/docs/sql-ref-syntax-aux-show-views.md @@ -51,7 +51,7 @@ SHOW VIEWS [ { FROM | IN } database_name ] [ LIKE 'regex_pattern' ] -### Example +### Examples {% highlight sql %} -- Create views in different databases, also create global/local temp views. CREATE VIEW sam AS SELECT id, salary FROM employee WHERE name = 'sam'; diff --git a/docs/sql-ref-syntax-ddl-alter-database.md b/docs/sql-ref-syntax-ddl-alter-database.md index 520aba35567e..65b85dcae15e 100644 --- a/docs/sql-ref-syntax-ddl-alter-database.md +++ b/docs/sql-ref-syntax-ddl-alter-database.md @@ -31,7 +31,7 @@ for a database and may be used for auditing purposes. {% highlight sql %} ALTER { DATABASE | SCHEMA } database_name - SET DBPROPERTIES ( property_name = property_value, ... ) + SET DBPROPERTIES ( property_name = property_value [ , ... ] ) {% endhighlight %} ### Parameters diff --git a/docs/sql-ref-syntax-ddl-alter-table.md b/docs/sql-ref-syntax-ddl-alter-table.md index edb081b7f45c..0a74aa0f843e 100644 --- a/docs/sql-ref-syntax-ddl-alter-table.md +++ b/docs/sql-ref-syntax-ddl-alter-table.md @@ -66,7 +66,7 @@ ALTER TABLE table_identifier partition_spec RENAME TO partition_spec #### Syntax {% highlight sql %} -ALTER TABLE table_identifier ADD COLUMNS ( col_spec [ , col_spec ... ] ) +ALTER TABLE table_identifier ADD COLUMNS ( col_spec [ , ... ] ) {% endhighlight %} #### Parameters @@ -84,7 +84,7 @@ ALTER TABLE table_identifier ADD COLUMNS ( col_spec [ , col_spec ... ] )
COLUMNS ( col_spec )
-
Specifies the columns to be added to be renamed.
+
Specifies the columns to be added.
### ALTER OR CHANGE COLUMN diff --git a/docs/sql-ref-syntax-ddl-alter-view.md b/docs/sql-ref-syntax-ddl-alter-view.md index 8116c97cc2f4..06c1b6534976 100644 --- a/docs/sql-ref-syntax-ddl-alter-view.md +++ b/docs/sql-ref-syntax-ddl-alter-view.md @@ -105,7 +105,7 @@ ALTER VIEW view_identifier UNSET TBLPROPERTIES [ IF EXISTS ] ( property_key [ , #### ALTER View AS SELECT -`ALTER VIEW view_identifier AS SELECT` statement changes the definition of a view, the `SELECT` statement must be valid, +`ALTER VIEW view_identifier AS SELECT` statement changes the definition of a view. The `SELECT` statement must be valid, and the `view_identifier` must exist. #### Syntax @@ -127,7 +127,7 @@ Note that `ALTER VIEW` statement does not support `SET SERDE` or `SET SERDEPROPE
select_statement
- Specifies the definition of the view, detail check select_statement + Specifies the definition of the view. Check select_statement for details.
@@ -136,7 +136,7 @@ Note that `ALTER VIEW` statement does not support `SET SERDE` or `SET SERDEPROPE {% highlight sql %} -- Rename only changes the view name. -- The source and target databases of the view have to be the same. --- Use qualified or unqualified name for the source and target view +-- Use qualified or unqualified name for the source and target view. ALTER VIEW tempdb1.v1 RENAME TO tempdb1.v2; -- Verify that the new view is created. diff --git a/docs/sql-ref-syntax-ddl-create-function.md b/docs/sql-ref-syntax-ddl-create-function.md index 2bd26d18c773..5009069b5f8f 100644 --- a/docs/sql-ref-syntax-ddl-create-function.md +++ b/docs/sql-ref-syntax-ddl-create-function.md @@ -28,8 +28,8 @@ all sessions. The resources specified in the `USING` clause are made available to all executors when they are executed for the first time. In addition to the SQL interface, spark allows users to create custom user defined scalar and aggregate functions using Scala, Python and Java APIs. Please refer to -[scalar_functions](sql-getting-started.html#scalar-functions) and -[aggregate functions](sql-getting-started#aggregations) for more information. +[Scalar UDFs](sql-ref-functions-udf-scalar.html) and +[UDAFs](sql-ref-functions-udf-aggregate.html) for more information. ### Syntax diff --git a/docs/sql-ref-syntax-ddl-create-table-datasource.md b/docs/sql-ref-syntax-ddl-create-table-datasource.md index 715b64c33bae..54827fd63568 100644 --- a/docs/sql-ref-syntax-ddl-create-table-datasource.md +++ b/docs/sql-ref-syntax-ddl-create-table-datasource.md @@ -28,7 +28,7 @@ The `CREATE TABLE` statement defines a new table using a Data Source. {% highlight sql %} CREATE TABLE [ IF NOT EXISTS ] table_identifier [ ( col_name1 col_type1 [ COMMENT col_comment1 ], ... ) ] - [USING data_source] + [ USING data_source ] [ OPTIONS ( key1=val1, key2=val2, ... ) ] [ PARTITIONED BY ( col_name1, col_name2, ... ) ] [ CLUSTERED BY ( col_name3, col_name4, ... ) diff --git a/docs/sql-ref-syntax-ddl-create-view.md b/docs/sql-ref-syntax-ddl-create-view.md index 5d9db2ab36b5..ba8c1df1223a 100644 --- a/docs/sql-ref-syntax-ddl-create-view.md +++ b/docs/sql-ref-syntax-ddl-create-view.md @@ -42,7 +42,7 @@ CREATE [ OR REPLACE ] [ [ GLOBAL ] TEMPORARY ] VIEW [ IF NOT EXISTS ] view_ident
[ GLOBAL ] TEMPORARY
TEMPORARY views are session-scoped and will be dropped when session ends because it skips persisting the definition in the underlying metastore, if any. - GLOBAL TEMPORARY views are tied to a system preserved temporary database `global_temp`.
+ GLOBAL TEMPORARY views are tied to a system preserved temporary database global_temp.
IF NOT EXISTS
@@ -64,7 +64,7 @@ CREATE [ OR REPLACE ] [ [ GLOBAL ] TEMPORARY ] VIEW [ IF NOT EXISTS ] view_ident
diff --git a/docs/sql-ref-syntax-ddl-drop-database.md b/docs/sql-ref-syntax-ddl-drop-database.md index 431139101eba..7467e7a4ad6e 100644 --- a/docs/sql-ref-syntax-ddl-drop-database.md +++ b/docs/sql-ref-syntax-ddl-drop-database.md @@ -27,14 +27,14 @@ exception will be thrown if the database does not exist in the system. ### Syntax {% highlight sql %} -DROP ( DATABASE | SCHEMA ) [ IF EXISTS ] dbname [ RESTRICT | CASCADE ] +DROP { DATABASE | SCHEMA } [ IF EXISTS ] dbname [ RESTRICT | CASCADE ] {% endhighlight %} ### Parameters
DATABASE | SCHEMA
-
`DATABASE` and `SCHEMA` mean the same thing, either of them can be used.
+
DATABASE and SCHEMA mean the same thing, either of them can be used.
@@ -52,7 +52,7 @@ DROP ( DATABASE | SCHEMA ) [ IF EXISTS ] dbname [ RESTRICT | CASCADE ]
If specified, will drop all the associated tables and functions.
-### Example +### Examples {% highlight sql %} -- Create `inventory_db` Database diff --git a/docs/sql-ref-syntax-ddl-drop-function.md b/docs/sql-ref-syntax-ddl-drop-function.md index f7ad18553e30..b783b0ebd2bc 100644 --- a/docs/sql-ref-syntax-ddl-drop-function.md +++ b/docs/sql-ref-syntax-ddl-drop-function.md @@ -27,19 +27,26 @@ be thrown if the function does not exist. ### Syntax {% highlight sql %} -DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] [ db_name. ] function_name +DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] function_name {% endhighlight %} ### Parameters
function_name
-
The name of an existing function.
+
+ Specifies the name of an existing function. The function name may be + optionally qualified with a database name.

+ Syntax: + + [ database_name. ] function_name + +
TEMPORARY
-
Should be used to delete the `temporary` function.
+
Should be used to delete the TEMPORARY function.
@@ -47,7 +54,7 @@ DROP [ TEMPORARY ] FUNCTION [ IF EXISTS ] [ db_name. ] function_name
If specified, no exception is thrown when the function does not exist.
-### Example +### Examples {% highlight sql %} -- Create a permanent function `test_avg` @@ -62,7 +69,8 @@ SHOW USER FUNCTIONS; +----------------+ -- Create Temporary function `test_avg` -CREATE TEMPORARY FUNCTION test_avg as 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage'; +CREATE TEMPORARY FUNCTION test_avg AS + 'org.apache.hadoop.hive.ql.udf.generic.GenericUDAFAverage'; -- List user functions SHOW USER FUNCTIONS; diff --git a/docs/sql-ref-syntax-ddl-drop-table.md b/docs/sql-ref-syntax-ddl-drop-table.md index 32a9cc7bb27d..c943b922ae81 100644 --- a/docs/sql-ref-syntax-ddl-drop-table.md +++ b/docs/sql-ref-syntax-ddl-drop-table.md @@ -49,7 +49,7 @@ DROP TABLE [ IF EXISTS ] table_identifier -### Example +### Examples {% highlight sql %} -- Assumes a table named `employeetable` exists. diff --git a/docs/sql-ref-syntax-ddl-drop-view.md b/docs/sql-ref-syntax-ddl-drop-view.md index ae976c125f5f..ad018b5e6fd5 100644 --- a/docs/sql-ref-syntax-ddl-drop-view.md +++ b/docs/sql-ref-syntax-ddl-drop-view.md @@ -46,7 +46,7 @@ DROP VIEW [ IF EXISTS ] view_identifier -### Example +### Examples {% highlight sql %} -- Assumes a view named `employeeView` exists. diff --git a/docs/sql-ref-syntax-ddl-truncate-table.md b/docs/sql-ref-syntax-ddl-truncate-table.md index 6377e8357020..e2d183430277 100644 --- a/docs/sql-ref-syntax-ddl-truncate-table.md +++ b/docs/sql-ref-syntax-ddl-truncate-table.md @@ -61,7 +61,7 @@ TRUNCATE TABLE table_identifier [ partition_spec ] -- Create table Student with partition CREATE TABLE Student (name STRING, rollno INT) PARTITIONED BY (age INT); -SELECT * from Student; +SELECT * FROM Student; +----+------+---+ |name|rollno|age| +----+------+---+ @@ -74,7 +74,7 @@ SELECT * from Student; TRUNCATE TABLE Student partition(age=10); -- After truncate execution, records belonging to partition age=10 are removed -SELECT * from Student; +SELECT * FROM Student; +----+------+---+ |name|rollno|age| +----+------+---+ @@ -84,7 +84,7 @@ SELECT * from Student; -- Removes all rows from the table from all partitions TRUNCATE TABLE Student; -SELECT * from Student; +SELECT * FROM Student; +----+------+---+ |name|rollno|age| +----+------+---+ diff --git a/docs/sql-ref-syntax-dml-insert-into.md b/docs/sql-ref-syntax-dml-insert-into.md index ba65334ef8f6..249872660283 100644 --- a/docs/sql-ref-syntax-dml-insert-into.md +++ b/docs/sql-ref-syntax-dml-insert-into.md @@ -27,7 +27,7 @@ The `INSERT INTO` statement inserts new rows into a table. The inserted rows can {% highlight sql %} INSERT INTO [ TABLE ] table_identifier [ partition_spec ] - { { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] } | query } + { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query } {% endhighlight %} ### Parameters @@ -50,7 +50,7 @@ INSERT INTO [ TABLE ] table_identifier [ partition_spec ] for partitions.

Syntax: - PARTITION (partition_col_name = partition_col_val [ , ... ]) + PARTITION ( partition_col_name = partition_col_val [ , ... ] ) diff --git a/docs/sql-ref-syntax-dml-insert-overwrite-directory-hive.md b/docs/sql-ref-syntax-dml-insert-overwrite-directory-hive.md index 3ab0994cf06e..3cd2107668fb 100644 --- a/docs/sql-ref-syntax-dml-insert-overwrite-directory-hive.md +++ b/docs/sql-ref-syntax-dml-insert-overwrite-directory-hive.md @@ -29,7 +29,7 @@ Hive support must be enabled to use this command. The inserted rows can be speci {% highlight sql %} INSERT OVERWRITE [ LOCAL ] DIRECTORY directory_path [ ROW FORMAT row_format ] [ STORED AS file_format ] - { { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] } | query } + { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query } {% endhighlight %} ### Parameters diff --git a/docs/sql-ref-syntax-dml-insert-overwrite-directory.md b/docs/sql-ref-syntax-dml-insert-overwrite-directory.md index 645396620f21..6ce7f50588e3 100644 --- a/docs/sql-ref-syntax-dml-insert-overwrite-directory.md +++ b/docs/sql-ref-syntax-dml-insert-overwrite-directory.md @@ -28,7 +28,7 @@ The `INSERT OVERWRITE DIRECTORY` statement overwrites the existing data in the d {% highlight sql %} INSERT OVERWRITE [ LOCAL ] DIRECTORY [ directory_path ] USING file_format [ OPTIONS ( key = val [ , ... ] ) ] - { { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] } | query } + { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query } {% endhighlight %} ### Parameters diff --git a/docs/sql-ref-syntax-dml-insert-overwrite-table.md b/docs/sql-ref-syntax-dml-insert-overwrite-table.md index added8e1976b..f2874b5ac230 100644 --- a/docs/sql-ref-syntax-dml-insert-overwrite-table.md +++ b/docs/sql-ref-syntax-dml-insert-overwrite-table.md @@ -27,7 +27,7 @@ The `INSERT OVERWRITE` statement overwrites the existing data in the table using {% highlight sql %} INSERT OVERWRITE [ TABLE ] table_identifier [ partition_spec [ IF NOT EXISTS ] ] - { { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] } | query } + { VALUES ( { value | NULL } [ , ... ] ) [ , ( ... ) ] | query } {% endhighlight %} ### Parameters diff --git a/docs/sql-ref-syntax-qry-select-usedb.md b/docs/sql-ref-syntax-qry-select-usedb.md index 2a0508521897..bb95a8e4ddf3 100644 --- a/docs/sql-ref-syntax-qry-select-usedb.md +++ b/docs/sql-ref-syntax-qry-select-usedb.md @@ -41,7 +41,7 @@ USE database_name -### Example +### Examples {% highlight sql %} -- Use the 'userdb' which exists. diff --git a/docs/sql-ref-syntax-qry.md b/docs/sql-ref-syntax-qry.md index 477c347eed80..325c9b69f12f 100644 --- a/docs/sql-ref-syntax-qry.md +++ b/docs/sql-ref-syntax-qry.md @@ -22,7 +22,8 @@ license: | Spark supports SELECT statement that is used to retrieve rows from one or more tables according to the specified clauses. The full syntax and brief description of supported clauses are explained in -[SELECT](sql-ref-syntax-qry-select.html) section. Spark also provides the +[SELECT](sql-ref-syntax-qry-select.html) section. The SQL statements related +to SELECT are also included in this section. Spark also provides the ability to generate logical and physical plan for a given query using [EXPLAIN](sql-ref-syntax-qry-explain.html) statement. @@ -34,4 +35,12 @@ ability to generate logical and physical plan for a given query using * [CLUSTER BY Clause](sql-ref-syntax-qry-select-clusterby.html) * [DISTRIBUTE BY Clause](sql-ref-syntax-qry-select-distribute-by.html) * [LIMIT Clause](sql-ref-syntax-qry-select-limit.html) + * [JOIN](sql-ref-syntax-qry-select-join.html) + * [Join Hints](sql-ref-syntax-qry-select-hints.html) + * [Set Operators](sql-ref-syntax-qry-select-setops.html) + * [TABLESAMPLE](sql-ref-syntax-qry-sampling.html) + * [Table-valued Function](sql-ref-syntax-qry-select-tvf.html) + * [Inline Table](sql-ref-syntax-qry-select-inline-table.html) + * [Common Table Expression](sql-ref-syntax-qry-select-cte.html) + * [Window Function](sql-ref-syntax-qry-window.html) * [EXPLAIN Statement](sql-ref-syntax-qry-explain.html)