Skip to content
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

[FLINK-23243][docs-zh]Translate "SELECT & WHERE clause" page into Chinese #16418

Merged
merged 11 commits into from Jul 12, 2021
Merged
17 changes: 9 additions & 8 deletions docs/content.zh/docs/dev/table/sql/queries/select.md
@@ -1,5 +1,5 @@
---
title: "SELECT & WHERE"
title: "SELECT WHERE"
weight: 4
type: docs
---
Expand All @@ -22,44 +22,45 @@ specific language governing permissions and limitations
under the License.
-->

# SELECT & WHERE clause
# SELECT WHERE 子句

{{< label Batch >}} {{< label Streaming >}}

The general syntax of the `SELECT` statement is:
`SELECT` 语句的常见语法格式如下所示:
edmondsky marked this conversation as resolved.
Show resolved Hide resolved

```sql
SELECT select_list FROM table_expression [ WHERE boolean_expression ]
```

The `table_expression` refers to any source of data. It could be an existing table, view, or `VALUES` clause, the joined results of multiple existing tables, or a subquery. Assuming that the table is available in the catalog, the following would read all rows from `Orders`.
这里的 `table_expression` 可以是任意的数据来源。它可以是一张已经存在的表、视图或者 `VALUES` 子句,也可以是多个现有表的关联结果、或一个子查询。这里我们假设 `Orders` 表在 `Catalog` 中处于可用状态,那么下面的语句会从 `Orders` 表中读出所有的行。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数据来源->数据源

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's all set. @RocMarshal


```sql
SELECT * FROM Orders
```

The `select_list` specification `*` means the query will resolve all columns. However, usage of `*` is discouraged in production because it makes queries less robust to catalog changes. Instead, a `select_list` can specify a subset of available columns or make calculations using said columns. For example, if `Orders` has columns named `order_id`, `price`, and `tax` you could write the following query:
`select_list` 处的 `*` 表示查询操作将会解析所有列。但是,我们不鼓励在生产中使用 `*` , 因为它会使查询操作在应对 `Catalog` 变化的时候鲁棒性降低。相反,我们可以在 `select_list` 处指定它为可用列的子集,或者使用声明过的列进行计算。例如,这里我们假设在 `Orders` 表中有名为 `order_id` `price`、 和 `tax` 的列,那么可以有以下查询语句:
edmondsky marked this conversation as resolved.
Show resolved Hide resolved

```sql
SELECT order_id, price + tax FROM Orders
```

Queries can also consume from inline data using the `VALUES` clause. Each tuple corresponds to one row and an alias may be provided to assign names to each column.
查询操作还可以在 `VALUES` 子句中使用内联数据。每一个元组对应一行,另外可以通过设置别名来为每一列指定名称。

```sql
SELECT order_id, price FROM (VALUES (1, 2.0), (2, 3.1)) AS t (order_id, price)
```

Rows can be filtered based on a `WHERE` clause.
可以根据 `WHERE` 子句对行数据进行过滤。

```sql
SELECT price + tax FROM Orders WHERE id = 10
```

Additionally, built-in and [user-defined scalar functions]({{< ref "docs/dev/table/functions/udfs" >}}) can be invoked on the columns of a single row. User-defined functions must be registered in a catalog before use.
此外,在任意一行的列上你可以调用内置函数和 [ 用户自定义标量函数 ( user-defined scalar functions]({{< ref "docs/dev/table/functions/udfs" >}}) 。当然,在使用前用户自定义函数( user-defined functions )必须已经注册到 `Catalog` 中。
edmondsky marked this conversation as resolved.
Show resolved Hide resolved

```sql
SELECT PRETTY_PRINT(order_id) FROM Orders
```

{{< top >}}