huaxingao commented on a change in pull request #29056: URL: https://github.com/apache/spark/pull/29056#discussion_r456849627
########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. Review comment: typo: Parameters ########## File path: docs/sql-ref-syntax-qry-select-groupby.md ########## @@ -91,6 +93,18 @@ aggregate_name ( [ DISTINCT ] expression [ , ... ] ) [ FILTER ( WHERE boolean_ex Filters the input rows for which the `boolean_expression` in the `WHERE` clause evaluates to true are passed to the aggregate function; other rows are discarded. +* **FIRST** + + `FIRST` selects a first expression value from the data set. We can specify an optional `IGNORE NULL` clause to ignore NULL values. Review comment: I thought data set is one word. I searched docs, both data set and dataset are used, so I guess either way is OK. ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. + +* **table_alias** + + It is the alias for `generator_function`, which is optional. + +* **column_alias** + + It lists the column aliases of `generator_function`, which may be used in output rows, we may have multiple alias if `generator_function` have multiple output columns. Review comment: Remove it? , we -> . We? multiple alias -> multiple aliases? ``` Lists the column aliases of `generator_function`, which may be used in output rows. We may have multiple aliases if `generator_function` has multiple output columns. ``` ########## File path: docs/sql-ref-syntax-qry-select-pivot.md ########## @@ -0,0 +1,101 @@ +--- +layout: global +title: PIVOT Clause +displayTitle: PIVOT 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 + +`PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value, which will be turned to multiple columns used in `SELECT Clause`, `PIVOT` clause can be specified after the table name or subquery. Review comment: change to ``` The `PIVOT` clause is used for data perspective: we can get the aggregated values based on the specific column value, which will be turned into multiple columns used in `SELECT Clause`. The `PIVOT` clause can be specified after the table name or subquery. ``` ########## File path: docs/sql-ref-syntax-ddl-create-table-hiveformat.md ########## @@ -51,15 +59,55 @@ as any order. For example, you can write COMMENT table_comment after TBLPROPERTI * **EXTERNAL** - Table is defined using the path provided as LOCATION, does not use default location for this table. + Table is defined using the path provided as `LOCATION`, does not use default location for this table. * **PARTITIONED BY** Partitions are created on the table, based on the columns specified. + +* **row_format** + + Use the `SERDE` clause to specify a custom SerDe for one table. Otherwise, use the `DELIMITED` clause to use the native SerDe and specify the delimiter, escape character, null character, and so on. + +* **SERDE** + + `SERDE` clause can be used to specify a custom `SerDe` for one table. + +* **serde_class** + + Specify a fully-qualified class name of a custom SerDe. + +* **SERDEPROPERTIES** + + A list of key-value pairs that is used to tag the serde definition. + +* **DELIMITED** + + `DELIMITED` clause can be used to specify the native `SerDe` and state the delimiter, escape character, null character, and so on. + +* **FIELDS TERMINATED BY** -* **ROW FORMAT** + It is used to define a column separator. Review comment: remove `it is`? It is used to define a column separator -> Used to define a column separator? Same for the next a few sentences. ########## File path: docs/sql-ref-syntax-ddl-create-table-hiveformat.md ########## @@ -51,15 +59,55 @@ as any order. For example, you can write COMMENT table_comment after TBLPROPERTI * **EXTERNAL** - Table is defined using the path provided as LOCATION, does not use default location for this table. + Table is defined using the path provided as `LOCATION`, does not use default location for this table. * **PARTITIONED BY** Partitions are created on the table, based on the columns specified. + +* **row_format** + + Use the `SERDE` clause to specify a custom SerDe for one table. Otherwise, use the `DELIMITED` clause to use the native SerDe and specify the delimiter, escape character, null character, and so on. + +* **SERDE** + + `SERDE` clause can be used to specify a custom `SerDe` for one table. + +* **serde_class** + + Specify a fully-qualified class name of a custom SerDe. + +* **SERDEPROPERTIES** + + A list of key-value pairs that is used to tag the serde definition. Review comment: serde -> SerDe ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. Review comment: `LATERAL VIEW` clause -> The `LATERAL VIEW` clause ########## File path: docs/sql-ref-syntax-qry-select-groupby.md ########## @@ -91,6 +93,18 @@ aggregate_name ( [ DISTINCT ] expression [ , ... ] ) [ FILTER ( WHERE boolean_ex Filters the input rows for which the `boolean_expression` in the `WHERE` clause evaluates to true are passed to the aggregate function; other rows are discarded. +* **FIRST** + + `FIRST` selects a first expression value from the data set. We can specify an optional `IGNORE NULL` clause to ignore NULL values. + +* **LAST** + + `LAST` select a last expression value from the data set, we can specify `IGNORE NULLS` to ignore NULLS, it is optional. Review comment: change to ``` `LAST` selects a last expression value from the data set. We can specify an optional `IGNORE NULL` clause to ignore NULL values. ``` ########## File path: docs/sql-ref-syntax-qry-select-case.md ########## @@ -0,0 +1,107 @@ +--- +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 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 +``` + +### Parameters + +* **boolean_expression** + + Specifies an expression with a return type of boolean. + +* **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. Review comment: expression, -> expression; ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. Review comment: typo Parameters there is an extra space after `for` ########## File path: docs/sql-ref-syntax-qry-select-case.md ########## @@ -0,0 +1,107 @@ +--- +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 specific result based on the specified condition, similar to if/else statements in other programming languages. Review comment: return specific result -> return a specific result? ########## File path: docs/sql-ref-syntax-qry-select-case.md ########## @@ -0,0 +1,107 @@ +--- +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 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 +``` + +### Parameters + +* **boolean_expression** + + Specifies an expression with a return type of boolean. + +* **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. Review comment: These are two sentences. use `;` instead of `,`? condition, -> condition; ########## File path: docs/sql-ref-syntax-qry-select-groupby.md ########## @@ -91,6 +93,18 @@ aggregate_name ( [ DISTINCT ] expression [ , ... ] ) [ FILTER ( WHERE boolean_ex Filters the input rows for which the `boolean_expression` in the `WHERE` clause evaluates to true are passed to the aggregate function; other rows are discarded. +* **FIRST** + + `FIRST` selects a first expression value from the data set. We can specify an optional `IGNORE NULL` clause to ignore NULL values. + +* **LAST** + + `LAST` select a last expression value from the data set, we can specify `IGNORE NULLS` to ignore NULLS, it is optional. + +* **IGNORE NULLS** + + `IGNORE NULLS` is to ignore null values, which is used in `FIRST` and `LAST` Review comment: change to ``` `IGNORE NULLS` is used to ignore null values, which are used in `FIRST` and `LAST`. ``` ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. Review comment: with single input row -> with a single input row? ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. Review comment: Add `The` in the beginning? ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. + +* **table_alias** + + It is the alias for `generator_function`, which is optional. Review comment: I think you can remove It is. ``` The alias for `generator_function`, which is optional. ``` ########## File path: docs/sql-ref-syntax-qry-select-pivot.md ########## @@ -0,0 +1,101 @@ +--- +layout: global +title: PIVOT Clause +displayTitle: PIVOT 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 + +`PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value, which will be turned to multiple columns used in `SELECT Clause`, `PIVOT` clause can be specified after the table name or subquery. + +### Syntax + +```sql +PIVOT ( { aggregate_expression [ AS aggregate_expression_alias ] } [ , ... ] + FOR column_list IN ( expression_list ) ) +``` + +### Parameters + +* **aggregate_expression** + + Specifies an aggregate expression (SUM(a), COUNT(DISTINCT b), etc.). + +* **aggregate_expression_alias** + + Specifies an alias for aggregate expression. + +* **column_list** + + It contains columns in the `FROM` clause, which specifies the columns we want to replaced with new columns, we can use brackets to surround the columns, such as `( c1, c2 )`. + +* **expression_list** + + It specifies new columns, which used to match values in `column_List` as the aggregating condition, we can also add alias for them. Review comment: change to ``` Specifies new columns, which are used to match values in `column_List` as the aggregating condition. We can also add aliases for them. ``` ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. + +* **table_alias** + + It is the alias for `generator_function`, which is optional. Review comment: remove it is? ```The alias for `generator_function`, which is optional.``` ########## File path: docs/sql-ref-syntax-qry-select-pivot.md ########## @@ -0,0 +1,101 @@ +--- +layout: global +title: PIVOT Clause +displayTitle: PIVOT 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 + +`PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value, which will be turned to multiple columns used in `SELECT Clause`, `PIVOT` clause can be specified after the table name or subquery. Review comment: Add `The` in the beginning? `,` -> `:`? turned to -> turned into? , `PIVOT` -> . `PIVOT`? ``` The `PIVOT` clause is used for data perspective: we can get the aggregated values based on the specific column value, which will be turned into multiple columns used in the `SELECT Clause`. The `PIVOT` clause can be specified after the table name or subquery. ``` ########## File path: docs/sql-ref-syntax-qry-select-lateral-view.md ########## @@ -0,0 +1,130 @@ +--- +layout: global +title: LATERAL VIEW Clause +displayTitle: LATERAL VIEW 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 + +`LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. + +### Syntax + +```sql +LATERAL VIEW [ OUTER ] generator_function ( expression [ , ... ] ) [ table_alias ] AS column_alias [ , ... ] +``` + +### Parameters + +* **OUTER** + + If `LATERAL VIEW` is used without `OUTER`, and `generator_function` returns empty, then no results will be output in `SELECT` clause. + If `LATERAL VIEW` is used with `OUTER`, and `generator_function` returns empty, then results will be output normally with `NULL` as `generator_function` output. + +* **generator_function** + + This expression will output a virtual table with single input row. + +* **expression** + + Paramters for generating_function. + +* **table_alias** + + It is the alias for `generator_function`, which is optional. + +* **column_alias** + + It lists the column aliases of `generator_function`, which may be used in output rows, we may have multiple alias if `generator_function` have multiple output columns. Review comment: change to ``` Lists the column aliases of `generator_function`, which may be used in output rows. We may have multiple aliases if `generator_function` has multiple output columns. ``` ########## File path: docs/sql-ref-syntax-qry-select.md ########## @@ -83,8 +85,15 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { named_expression [ , ... ] } * [Table-value function](sql-ref-syntax-qry-select-tvf.html) * [Inline table](sql-ref-syntax-qry-select-inline-table.html) * Subquery + + * **PIVOT** + `PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value. + * **LATERAL VIEW** + + `LATERAL VIEW` clause is used in conjunction with generator functions such as explode(), which will generate a virtual table containing one or more rows. `LATERAL VIEW` will apply the rows to each original output row. Review comment: Add `The` in the beginning? ########## File path: docs/sql-ref-syntax-qry-select-pivot.md ########## @@ -0,0 +1,101 @@ +--- +layout: global +title: PIVOT Clause +displayTitle: PIVOT 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 + +`PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value, which will be turned to multiple columns used in `SELECT Clause`, `PIVOT` clause can be specified after the table name or subquery. + +### Syntax + +```sql +PIVOT ( { aggregate_expression [ AS aggregate_expression_alias ] } [ , ... ] + FOR column_list IN ( expression_list ) ) +``` + +### Parameters + +* **aggregate_expression** + + Specifies an aggregate expression (SUM(a), COUNT(DISTINCT b), etc.). + +* **aggregate_expression_alias** + + Specifies an alias for aggregate expression. + +* **column_list** + + It contains columns in the `FROM` clause, which specifies the columns we want to replaced with new columns, we can use brackets to surround the columns, such as `( c1, c2 )`. Review comment: `It contains` -> `Contains` `replaced` -> `replace` `, we` -> `.We` ########## File path: docs/sql-ref-syntax-qry-select.md ########## @@ -83,8 +85,15 @@ SELECT [ hints , ... ] [ ALL | DISTINCT ] { named_expression [ , ... ] } * [Table-value function](sql-ref-syntax-qry-select-tvf.html) * [Inline table](sql-ref-syntax-qry-select-inline-table.html) * Subquery + + * **PIVOT** + `PIVOT` clause is used for data perspective, we can get the aggregated values based on specific column value. Review comment: Add `The` in the beginning? I guess `,` -> `:`? ---------------------------------------------------------------- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
