This is an automated email from the ASF dual-hosted git repository. kassiez pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push: new 00d1873e44c update subquery document (#1422) 00d1873e44c is described below commit 00d1873e44c72b033854d296642d3ee4fe7ee642 Author: starocean999 <li...@selectdb.com> AuthorDate: Tue Dec 10 20:35:42 2024 +0800 update subquery document (#1422) ## Versions - [x] dev - [x] 3.0 - [ ] 2.1 - [ ] 2.0 ## Languages - [x] Chinese - [x] English ## Docs Checklist - [ ] Checked by AI - [ ] Test Cases Built --- docs/query-data/subquery.md | 14 +++++++------- .../current/query-data/subquery.md | 14 +++++++------- .../version-3.0/query-data/subquery.md | 14 +++++++------- versioned_docs/version-3.0/query-data/subquery.md | 14 +++++++------- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/docs/query-data/subquery.md b/docs/query-data/subquery.md index 9e46b6eae3a..78d7618a81d 100644 --- a/docs/query-data/subquery.md +++ b/docs/query-data/subquery.md @@ -304,20 +304,20 @@ With this flag, the `where` filtering condition can be rewritten as `where mark_ ## Common Issues -Since the output of a scalar subquery must be a single value, Doris adopts different processing methods for correlated and non-correlated scalar subqueries. +Since the output of a scalar subquery must be a single value, a runtime error will be reported when the subquery returns more than one row of data. ### For Correlated Scalar Subqueries -Currently, Doris can only statically ensure that the subquery outputs a single value (i.e., a single aggregate function without `group by`). Therefore, when using correlated scalar subqueries, a `group by`-less aggregate function such as `any_value` needs to be added according to requirements, so that the optimizer can recognize the single-value semantics smoothly. Users need to ensure that the subquery always returns only one value. If the subquery actually returns multiple values (othe [...] +When using a correlated quantifier subquery, if the subquery that satisfies the correlation condition returns more than one row of data, a runtime error will be reported. Please refer to the following SQL example: ```sql --- Correlated scalar subquery lacking a single aggregate function without group by, currently not supported -select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; - --- Add a single aggregate function for the optimizer to recognize smoothly -select t1.*, (select any_value(t2.c1) from t2 where t1.c2 = t2.c2) from t1; +-- If there are more than 1 row in the t2 table that satisfies t1.c2 = t2.c2 in the associated scalar subquery, a runtime error will be reported +select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; + +-- Example error message +ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT][E33] correlate scalar subquery must return only 1 row ``` ### For Non-Correlated Scalar Subqueries diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/subquery.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/subquery.md index 88e4c8b5b05..ee0ccb41a5c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/subquery.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/query-data/subquery.md @@ -302,25 +302,25 @@ where ## 常见问题 -由于标量子查询的输出必须是一个单值,Doris 对于关联和非关联的标量子查询采取了不同的处理方式。 +由于标量子查询的输出必须是一个单值,如果子查询返回的数据量超过一条记录,将会报告运行时错误。 ### 对于关联的标量子查询 -目前 Doris 暂时只能以静态的方式确保子查询输出为单值(即没有 `group by` 的单个聚合函数)。因此,在使用关联标量子查询时,需要根据需求添加没有 `group by` 的聚合函数,如`any_value`,以便优化器能顺利识别单值语义。用户需要保证子查询一定只返回一个值,如果子查询实际返回多个值(其他数据库系统会在运行时报错),由于添加了聚合函数,它始终只返回一个值,虽然能得到结果,但可能和预期不符。 +在使用关联标量子查询时,如果满足关联条件的子查询返回的数据量超过一条记录,将会报告运行时错误。 请参考以下 SQL 示例: ```sql --- 关联的标量子查询,缺少单个无 group by 的聚合函数,目前不支持 -select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; +-- 关联的标量子查询,如果t2表中满足t1.c2 = t2.c2的数据多于 1 条,则会报运行时错误 +select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; --- 添加单个聚合函数,让优化器顺利识别 -select t1.*, (select any_value(t2.c1) from t2 where t1.c2 = t2.c2) from t1; +-- 报错信息样例如下 +ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT][E33] correlate scalar subquery must return only 1 row ``` ### 对于非关联的标量子查询 -Doris 会在运行时添加一个`assert num rows`算子,如果子查询返回的数据大于一条,则会报一个运行时错误。 +Doris 会在运行时添加一个`assert num rows`算子,如果子查询返回的数据量超过一条记录,将会报告运行时错误。 请参考以下 SQL 示例: diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/query-data/subquery.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/query-data/subquery.md index 88e4c8b5b05..81378c0278f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/query-data/subquery.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/query-data/subquery.md @@ -302,25 +302,25 @@ where ## 常见问题 -由于标量子查询的输出必须是一个单值,Doris 对于关联和非关联的标量子查询采取了不同的处理方式。 +标量子查询必须输出单一值。若子查询返回的数据量超过一条记录,将会报告运行时错误。 ### 对于关联的标量子查询 -目前 Doris 暂时只能以静态的方式确保子查询输出为单值(即没有 `group by` 的单个聚合函数)。因此,在使用关联标量子查询时,需要根据需求添加没有 `group by` 的聚合函数,如`any_value`,以便优化器能顺利识别单值语义。用户需要保证子查询一定只返回一个值,如果子查询实际返回多个值(其他数据库系统会在运行时报错),由于添加了聚合函数,它始终只返回一个值,虽然能得到结果,但可能和预期不符。 +在使用关联标量子查询时,如果满足关联条件的子查询返回的数据量超过一条记录,将会报告运行时错误。 请参考以下 SQL 示例: ```sql --- 关联的标量子查询,缺少单个无 group by 的聚合函数,目前不支持 -select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; +-- 关联的标量子查询,如果t2表中满足t1.c2 = t2.c2的数据多于 1 条,则会报运行时错误 +select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; --- 添加单个聚合函数,让优化器顺利识别 -select t1.*, (select any_value(t2.c1) from t2 where t1.c2 = t2.c2) from t1; +-- 报错信息样例如下 +ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT][E33] correlate scalar subquery must return only 1 row ``` ### 对于非关联的标量子查询 -Doris 会在运行时添加一个`assert num rows`算子,如果子查询返回的数据大于一条,则会报一个运行时错误。 +Doris 会在运行时添加一个`assert num rows`算子,如果子查询返回的数据量超过一条记录,将会报告运行时错误。 请参考以下 SQL 示例: diff --git a/versioned_docs/version-3.0/query-data/subquery.md b/versioned_docs/version-3.0/query-data/subquery.md index 9e46b6eae3a..78d7618a81d 100644 --- a/versioned_docs/version-3.0/query-data/subquery.md +++ b/versioned_docs/version-3.0/query-data/subquery.md @@ -304,20 +304,20 @@ With this flag, the `where` filtering condition can be rewritten as `where mark_ ## Common Issues -Since the output of a scalar subquery must be a single value, Doris adopts different processing methods for correlated and non-correlated scalar subqueries. +Since the output of a scalar subquery must be a single value, a runtime error will be reported when the subquery returns more than one row of data. ### For Correlated Scalar Subqueries -Currently, Doris can only statically ensure that the subquery outputs a single value (i.e., a single aggregate function without `group by`). Therefore, when using correlated scalar subqueries, a `group by`-less aggregate function such as `any_value` needs to be added according to requirements, so that the optimizer can recognize the single-value semantics smoothly. Users need to ensure that the subquery always returns only one value. If the subquery actually returns multiple values (othe [...] +When using a correlated quantifier subquery, if the subquery that satisfies the correlation condition returns more than one row of data, a runtime error will be reported. Please refer to the following SQL example: ```sql --- Correlated scalar subquery lacking a single aggregate function without group by, currently not supported -select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; - --- Add a single aggregate function for the optimizer to recognize smoothly -select t1.*, (select any_value(t2.c1) from t2 where t1.c2 = t2.c2) from t1; +-- If there are more than 1 row in the t2 table that satisfies t1.c2 = t2.c2 in the associated scalar subquery, a runtime error will be reported +select t1.*, (select t2.c1 from t2 where t1.c2 = t2.c2) from t1; + +-- Example error message +ERROR 1105 (HY000): errCode = 2, detailMessage = (127.0.0.1)[INVALID_ARGUMENT][E33] correlate scalar subquery must return only 1 row ``` ### For Non-Correlated Scalar Subqueries --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org