This is an automated email from the ASF dual-hosted git repository. luzhijing 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 500515d2bf2 [tvf] fix default column separator issue (#825) 500515d2bf2 is described below commit 500515d2bf2cffd0dfbb6564cbc74011e7006c3b Author: Mingyu Chen <morning...@163.com> AuthorDate: Mon Jul 8 21:22:49 2024 +0800 [tvf] fix default column separator issue (#825) Co-authored-by: Luzhijing <82810928+luzhij...@users.noreply.github.com> --- .../sql-functions/table-functions/hdfs.md | 4 +- .../sql-manual/sql-functions/table-functions/s3.md | 16 +-- .../sql-functions/table-functions/hdfs.md | 42 +++---- .../sql-manual/sql-functions/table-functions/s3.md | 124 ++++++++++----------- .../sql-functions/table-functions/hdfs.md | 41 +++---- .../sql-manual/sql-functions/table-functions/s3.md | 2 +- .../sql-functions/table-functions/hdfs.md | 42 +++---- .../sql-manual/sql-functions/table-functions/s3.md | 124 ++++++++++----------- .../sql-functions/table-functions/hdfs.md | 4 +- .../sql-manual/sql-functions/table-functions/s3.md | 11 +- .../sql-functions/table-functions/hdfs.md | 4 +- .../sql-manual/sql-functions/table-functions/s3.md | 16 +-- 12 files changed, 205 insertions(+), 225 deletions(-) diff --git a/docs/sql-manual/sql-functions/table-functions/hdfs.md b/docs/sql-manual/sql-functions/table-functions/hdfs.md index 7a281e06c60..61c19aa0ff6 100644 --- a/docs/sql-manual/sql-functions/table-functions/hdfs.md +++ b/docs/sql-manual/sql-functions/table-functions/hdfs.md @@ -62,6 +62,7 @@ Related parameters for accessing hdfs: - `dfs.domain.socket.path`: (optional) Related parameters for accessing HDFS in HA mode: + - `dfs.nameservices`: (optional) - `dfs.ha.namenodes.your-nameservices`: (optional) - `dfs.namenode.rpc-address.your-nameservices.your-namenode`: (optional) @@ -70,7 +71,7 @@ Related parameters for accessing HDFS in HA mode: File format parameters: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -115,6 +116,7 @@ MySQL [(none)]> select * from hdfs( ``` Read and access csv format files on hdfs storage in HA mode. + ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", diff --git a/docs/sql-manual/sql-functions/table-functions/s3.md b/docs/sql-manual/sql-functions/table-functions/s3.md index 5d7e25816c3..05f62a13fd1 100644 --- a/docs/sql-manual/sql-functions/table-functions/s3.md +++ b/docs/sql-manual/sql-functions/table-functions/s3.md @@ -27,6 +27,7 @@ under the License. ## S3 ### Name + S3 ### description @@ -61,13 +62,15 @@ Related parameters for accessing S3: - `use_path_style`: (optional) default `false` . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the `use_path_style` parameter to force the use of path style access method. - `force_parsing_by_standard_uri`: (optional) default `false` . We can add `force_parsing_by_standard_uri` parameter to force parsing unstandard uri as standard uri. -> Note: +> Note: > For AWS S3, standard uri styles should be: +> > 1. AWS Client Style(Hadoop S3 Style): > `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88` > 2. Virtual Host Style: > `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 3. Path Style: > `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > > In addition to supporting the common uri styles of the above three > standards, it also supports some other uri styles (maybe not common, but > there may be): +> > 1. Virtual Host AWS Client (Hadoop S3) Mixed Style: > `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 2. Path AWS Client (Hadoop S3) Mixed Style: @@ -78,7 +81,7 @@ Related parameters for accessing S3: file format parameter: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -128,7 +131,8 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c s3, table-valued-function, tvf ### Best Practice -Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. + +Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. **Usage of different uri schemas** Example of http:// 、https:// @@ -184,7 +188,7 @@ select * from s3( // MinIO select * from s3( "uri" = "s3://bucket/file.csv", - "s3.endpoint" = "http://172.21.0.101:9000", + "s3.endpoint" = "<http://172.21.0.101:9000>", "s3.access_key"= "ak", "s3.secret_key" = "sk", "s3.region" = "us-east-1", @@ -227,10 +231,8 @@ select * from s3( "force_parsing_by_standard_uri"="true"); ``` - **csv format** `csv` format: Read the file on S3 and process it as a csv file, read the first line in the file to parse out the table schema. The number of columns in the first line of the file `n` will be used as the number of columns in the table schema, and the column names of the table schema will be automatically named `c1, c2, ..., cn`, and the column type is set to `String` , for example: - The file content of student1.csv: @@ -317,7 +319,7 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi | age | TEXT | Yes | false | NULL | NONE | +-------+------+------+-------+---------+-------+ ``` - + **csv_with_names_and_types format** `csv_with_names_and_types` format: Currently, it does not support parsing the column type from a csv file. When using this format, S3 tvf will parse the first line of the file as the number and name of the columns of the table schema, and set the column type to String. Meanwhile, the second line of the file is ignored. diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/hdfs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/hdfs.md index 4ea148cf58f..ea8e6343ad9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/hdfs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/hdfs.md @@ -26,17 +26,9 @@ under the License. ## HDFS -### Name - -<version since="1.2"> - -hdfs - -</version> - ### Description -HDFS表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 +HDFS 表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 #### syntax ```sql @@ -52,10 +44,10 @@ hdfs( **参数说明** -访问hdfs相关参数: -- `uri`:(必填) 访问hdfs的uri。如果uri路径不存在或文件都是空文件,hdfs tvf将返回空集合。 +访问 HDFS 相关参数: +- `uri`:(必填)访问 HDFS 的 uri。如果 uri 路径不存在或文件都是空文件,HDFS TVF 将返回空集合。 - `fs.defaultFS`:(必填) -- `hadoop.username`: (必填)可以是任意字符串,但不能为空 +- `hadoop.username`:(必填)可以是任意字符串,但不能为空 - `hadoop.security.authentication`:(选填) - `hadoop.username`:(选填) - `hadoop.kerberos.principal`:(选填) @@ -69,13 +61,13 @@ hdfs( - `dfs.namenode.rpc-address.your-nameservices.your-namenode`:(选填) - `dfs.client.failover.proxy.provider.your-nameservices`:(选填) -文件格式相关参数 +文件格式相关参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`:(选填) 列分割符, 默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 -- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。 默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 +- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 - 下面6个参数是用于json格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) + 下面 6 个参数是用于 JSON 格式的导入,具体使用方法可以参照:[JSON Load](../../../data-operate/import/import-way/load-json-format.md) - `read_json_by_line`: (选填) 默认为 `"true"` - `strip_outer_array`: (选填) 默认为 `"false"` @@ -84,18 +76,18 @@ hdfs( - `num_as_string`: (选填) 默认为 `false` - `fuzzy_parse`: (选填) 默认为 `false` - <version since="dev">下面2个参数是用于csv格式的导入</version> + 下面 2 个参数用于 CSV 格式的导入: -- `trim_double_quotes`: 布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 csv 文件每个字段最外层的双引号 -- `skip_lines`: 整数类型,选填,默认值为0,含义为跳过csv文件的前几行。当设置format设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 +- `trim_double_quotes`:布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 CSV 文件每个字段最外层的双引号 +- `skip_lines`:整数类型,选填,默认值为 0,含义为跳过 CSV 文件的前几行。当设置 Format 设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 其他参数: - `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定resource名,hdfs tvf 可以利用已有的 hdfs resource 来直接访问hdfs。创建 hdfs resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `resource`:(选填)指定 Resource 名,HDFS TVF 可以利用已有的 HFDS Resource 来直接访问 HDFS。创建 HDFS Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 ### Examples -读取并访问 HDFS 存储上的csv格式文件 +读取并访问 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -113,7 +105,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -读取并访问 HA 模式的 HDFS 存储上的csv格式文件 +读取并访问 HA 模式的 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -136,7 +128,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -可以配合`desc function`使用 +可以配合 `desc function` 使用。 ```sql MySQL [(none)]> desc function hdfs( @@ -148,8 +140,8 @@ MySQL [(none)]> desc function hdfs( ### Keywords - hdfs, table-valued-function, tvf + HDFS, table-valued-function, TVF ### Best Practice - 关于HDFS tvf的更详细使用方法可以参照 [S3](./s3.md) tvf, 唯一不同的是访问存储系统的方式不一样。 + 关于 HDFS TVF 的更详细使用方法可以参照 [S3](./s3.md) TVF, 唯一不同的是访问存储系统的方式不一样。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/s3.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/s3.md index 8a915954014..b5c718d271b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/s3.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/table-functions/s3.md @@ -28,15 +28,11 @@ under the License. ### Name -<version since="1.2"> - s3 -</version> - ### description -S3表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 S3 兼容的对象存储上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 +S3 表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 S3 兼容的对象存储上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 **语法** @@ -54,22 +50,22 @@ s3( **参数说明** -S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 -访问S3相关参数: -- `uri`: (必填) 访问S3的uri,S3表函数会根据 `use_path_style` 参数来决定是否使用 path style 访问方式,默认为 virtual-hosted style 方式 +S3 TVF 中的每一个参数都是一个 `"key"="value"` 对。 +访问 S3 相关参数: +- `uri`: (必填) 访问 S3 的 URI,S3 表函数会根据 `use_path_style` 参数来决定是否使用 Path Style 访问方式,默认为 Virtual-hosted Style 方式 - `s3.access_key`: (必填) - `s3.secret_key`: (必填) -- `s3.region`: (选填)。如果Minio服务设置了其他的region,那么必填,否则默认使用`us-east-1`。 +- `s3.region`: (选填)。如果 Minio 服务设置了其他的 Region,那么必填,否则默认使用`us-east-1`。 - `s3.session_token`: (选填) -- `use_path_style`:(选填) 默认为`false` 。S3 SDK 默认使用 virtual-hosted style 方式。但某些对象存储系统可能没开启或没支持virtual-hosted style 方式的访问,此时我们可以添加 use_path_style 参数来强制使用 path style 方式。比如 `minio`默认情况下只允许`path style`访问方式,所以在访问minio时要加上`use_path_style=true`。 -- `force_parsing_by_standard_uri`:(选填)默认 `false` 。 我们可以添加 `force_parsing_by_standard_uri` 参数来强制将非标准的 uri 解析为标准 uri。 +- `use_path_style`:(选填) 默认为`false` 。S3 SDK 默认使用 Virtual-hosted Syle 方式。但某些对象存储系统可能没开启或没支持 Virtual-hosted Style 方式的访问,此时我们可以添加 `use_path_style` 参数来强制使用 Path Style 方式。比如 `minio` 默认情况下只允许 `path style` 访问方式,所以在访问 MinIO 时要加上 `use_path_style=true`。 +- `force_parsing_by_standard_uri`:(选填)默认 `false` 。我们可以添加 `force_parsing_by_standard_uri` 参数来强制将非标准的 URI 解析为标准 URI。 > 对于 AWS S3,标准 uri styles 有以下几种: > 1. AWS Client Style(Hadoop S3 Style): > `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`。 -> 2. Virtual Host Style:`https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 -> 3. Path Style:`https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 +> 2. Virtual Host Style:`https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 +> 3. Path Style:`https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 > -> 除了支持以上三个标准常见的 uri styles, 还支持其他一些 uri styles(也许不常见,但也有可能有): +> 除了支持以上三个标准常见的 URI Styles, 还支持其他一些 URI Styles(也许不常见,但也有可能有): > 1. Virtual Host AWS Client (Hadoop S3) Mixed Style: > `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 2. Path AWS Client (Hadoop S3) Mixed Style: @@ -79,11 +75,11 @@ S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 文件格式参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`:(选填) 列分割符, 默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 -- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。 默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 +- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 -下面6个参数是用于json格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) +下面 6 个参数是用于 JSON 格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) - `read_json_by_line`: (选填) 默认为 `"true"` - `strip_outer_array`: (选填) 默认为 `"false"` @@ -92,18 +88,18 @@ S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 - `num_as_string`: (选填) 默认为 `false` - `fuzzy_parse`: (选填) 默认为 `false` -下面2个参数是用于csv格式的导入 +下面 2 个参数是用于 CSV 格式的导入 -- `trim_double_quotes`: 布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 csv 文件每个字段最外层的双引号 -- `skip_lines`: 整数类型,选填,默认值为0,含义为跳过csv文件的前几行。当设置format设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 +- `trim_double_quotes`:布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 CSV 文件每个字段最外层的双引号 +- `skip_lines`:整数类型,选填,默认值为 0,含义为跳过 CSV 文件的前几行。当设置 format 设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 其他参数: -- `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定resource名,s3 tvf 可以利用已有的 s3 resource 来直接访问s3。创建 s3 resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如 `/path/to/city=beijing/date="2023-07-09"`, 则填写 `path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 +- `resource`:(选填)指定 Resource 名,S3 TVF 可以利用已有的 S3 Resource 来直接访问 S3。创建 S3 Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 ### Example -读取并访问 S3 兼容的对象存储上的csv格式文件 +读取并访问 S3 兼容的对象存储上的 CSV 格式文件 ```sql select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -114,7 +110,7 @@ select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", ``` -可以配合`desc function`使用 +可以配合 `desc function` 使用 ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -126,15 +122,15 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c ### Keywords - s3, table-valued-function, tvf + S3, table-valued-function, TVF ### Best Practice -**不同url schema的写法** +**不同 url schema 的写法** http:// 、https:// 使用示例: ```sql -// 注意URI bucket写法以及use_path_style参数设置,http同理。 -// 由于设置了"use_path_style"="true", 所以将采用path style方式访问s3。 +// 注意URI Bucket写法以及`use_path_style`参数设置,HTTP 同理。 +// 由于设置了 `"use_path_style"="true"`, 所以将采用 Path Style 的方式访问 S3。 select * from s3( "uri" = "https://endpoint/bucket/file/student.csv", "s3.access_key"= "ak", @@ -142,8 +138,8 @@ select * from s3( "format" = "csv", "use_path_style"="true"); -// 注意URI bucket写法以及use_path_style参数设置,http同理。 -// 由于设置了"use_path_style"="false", 所以将采用virtual-hosted style方式访问s3。 +// 注意 URI Bucket写法以及use_path_style参数设置,http同理。 +// 由于设置了 `"use_path_style"="false"`, 所以将采用 Virtual-hosted Style 方式访问 S3。 select * from s3( "uri" = "https://bucket.endpoint/bucket/file/student.csv", "s3.access_key"= "ak", @@ -151,7 +147,7 @@ select * from s3( "format" = "csv", "use_path_style"="false"); -// 阿里云oss和腾讯云cos采用virtual-hosted style方式访问s3。 +// 阿里云 OSS 和腾讯云 COS 采用 Virtual-hosted Style 方式访问 S3。 // OSS select * from s3( "uri" = "http://example-bucket.oss-cn-beijing.aliyuncs.com/your-folder/file.parquet", @@ -179,7 +175,7 @@ select * from s3( "format" = "csv" ); -// 百度云bos采用兼容s3协议的virtual-hosted style方式访问s3。 +// 百度云 BOS 采用兼容 S3 协议的 Virtual-hosted Style 方式访问 S3。 // BOS select * from s3( "uri" = "https://example-bucket.s3.bj.bcebos.com/your-folder/file.parquet", @@ -193,8 +189,8 @@ select * from s3( s3:// 使用示例: ```sql -// 注意URI bucket写法, 无需设置use_path_style参数。 -// 将采用virtual-hosted style方式访问s3。 +// 注意 URI Bucket 写法, 无需设置 `use_path_style` 参数。 +// 将采用 Virtual-hosted Style 方式访问 S3。 select * from s3( "uri" = "s3://bucket/file/student.csv", "s3.endpoint"= "endpont", @@ -204,7 +200,7 @@ select * from s3( "format" = "csv"); ``` -其它支持的 uri 风格示例: +其它支持的 URI 风格示例: ```sql // Virtual Host AWS Client (Hadoop S3) Mixed Style。通过设置 `use_path_style = false` 以及 `force_parsing_by_standard_uri = true` 来使用。 @@ -227,12 +223,12 @@ select * from s3( ``` -**csv format** -由于S3 table-valued-function事先并不知道table schema,所以会先读一遍文件来解析出table schema。 +**CSV format** +由于 S3 table-valued-function 事先并不知道 Table Schema,所以会先读一遍文件来解析出 Table Schema。 -`csv` 格式: S3 table-valued-function 读取S3上的文件并当作csv文件来处理,读取文件中的第一行用于解析table schema。文件第一行的列个数`n`将作为table schema的列个数,table schema的列名则自动取名为`c1, c2, ..., cn` ,列类型都设置为 `String`, 举例: +`csv` 格式:S3 table-valued-function 读取 S3 上的文件并当作 CSV 文件来处理,读取文件中的第一行用于解析 Table Schema。文件第一行的列个数 `n` 将作为 Table Schema 的列个数,Table Schema 的列名则自动取名为 `c1, c2, ..., cn` ,列类型都设置为 `String`, 举例: -student1.csv文件内容为: +student1.csv 文件内容为: ``` 1,ftw,12 @@ -240,7 +236,7 @@ student1.csv文件内容为: 3,ww,20 ``` -使用S3 tvf +使用 S3 TVF ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -257,7 +253,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.c +------+------+------+ ``` -可以配合 `desc function S3()` 来查看table schema +可以配合 `desc function S3()` 来查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -275,9 +271,9 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c ``` **csv_with_names format** -`csv_with_names`格式:解析文件的第一行作为table schema的列个数和列名,列类型则都设置为 `String`, 举例: +`csv_with_names` 格式:解析文件的第一行作为 Table Schema 的列个数和列名,列类型则都设置为 `String`, 举例: -student_with_names.csv文件内容为 +student_with_names.csv 文件内容为 ``` id,name,age @@ -286,7 +282,7 @@ id,name,age 3,ww,20 ``` -使用S3 tvf +使用 S3 tvf ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv", @@ -303,7 +299,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_wi +------+------+------+ ``` -同样配合`desc function S3()` 可查看table schema +同样配合 `desc function S3()` 可查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv", @@ -322,9 +318,9 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi **csv_with_names_and_types foramt** -`csv_with_names_and_types`格式:目前暂不支持从csv文件中解析出column type。使用该format时,S3 tvf会解析文件的第一行作为table schema的列个数和列名,列类型则都设置为 String,同时将忽略该文件的第二行。 +`csv_with_names_and_types` 格式:目前暂不支持从 CSV 文件中解析出 Column Type。使用该 Format 时,S3 TVF 会解析文件的第一行作为 Table Schema 的列个数和列名,列类型则都设置为 String,同时将忽略该文件的第二行。 -student_with_names_and_types.csv文件内容为 +`student_with_names_and_types.csv` 文件内容为 ``` id,name,age @@ -334,7 +330,7 @@ INT,STRING,INT 3,ww,20 ``` -使用S3 tvf +使用 S3 TVF ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv", @@ -351,7 +347,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_wi +------+------+------+ ``` -同样配合`desc function S3()` 可查看table schema +同样配合 `desc function S3()` 可查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv", @@ -368,11 +364,11 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi +-------+------+------+-------+---------+-------+ ``` -**json format** +**JSON format** -`json` 格式:json格式涉及到较多的可选参数,各个参数的意义可以参考:[Json Load](../../../data-operate/import/import-way/load-json-format.md)。 S3 tvf查询json格式文件时根据 `json_root` 和 `jsonpaths` 参数定位到一个json对象,将该对象的中的`key` 作为table schema的列名,列类型都设置为String。举例: +`json` 格式:JSON 格式涉及到较多的可选参数,各个参数的意义可以参考:[Json Load](../../../data-operate/import/import-way/load-json-format.md)。S3 TVF 查询 JSON 格式文件时根据 `json_root` 和 `jsonpaths` 参数定位到一个 JSON 对象,将该对象的中的 `key` 作为 Table Schema 的列名,列类型都设置为 String。举例: -data.json文件 +data.json 文件 ``` [{"id":1, "name":"ftw", "age":18}] @@ -380,7 +376,7 @@ data.json文件 [{"id":3, "name":"yyy", "age":19}] ``` -使用S3 tvf查询 +使用 S3 TVF 查询 ```sql MySQL [(none)]> select * from s3( @@ -416,9 +412,9 @@ MySQL [(none)]> select * from s3( +------+------+ ``` -**parquet format** +**Parquet format** -`parquet` 格式:S3 tvf支持从parquet文件中解析出table schema的列名、列类型。举例: +`parquet` 格式:S3 TVF 支持从 Parquet 文件中解析出 Table Schema 的列名、列类型。举例: ```sql MySQL [(none)]> select * from s3( @@ -462,7 +458,7 @@ MySQL [(none)]> desc function s3( **orc format** -`orc` 格式:和`parquet` format使用方法一致, 将`format`参数设置为orc。 +`orc` 格式:和 `parquet` format 使用方法一致,将 `format` 参数设置为 `orc`。 ```sql MySQL [(none)]> select * from s3( @@ -483,7 +479,7 @@ MySQL [(none)]> select * from s3( ``` **avro format** -`avro` 格式:S3 tvf支持从avro文件中解析出table schema的列名、列类型。举例: +`avro` 格式:S3 TVF 支持从 avro 文件中解析出 Table Schema 的列名、列类型。举例: ```sql select * from s3( @@ -500,10 +496,10 @@ select * from s3( +--------+--------------+-------------+-----------------+ ``` -**uri包含通配符** +**URI 包含通配符** -uri可以使用通配符来读取多个文件。注意:如果使用通配符要保证各个文件的格式是一致的(尤其是csv/csv_with_names/csv_with_names_and_types算做不同的格式),S3 tvf用第一个文件来解析出table schema。 -如下两个csv文件: +URI 可以使用通配符来读取多个文件。注意:如果使用通配符要保证各个文件的格式是一致的 (尤其是 `csv`/`csv_with_names`/`csv_with_names_and_types` 算做不同的格式),S3 TVF 用第一个文件来解析出 Table Schema。 +如下两个 CSV 文件: ``` // file1.csv @@ -516,7 +512,7 @@ uri可以使用通配符来读取多个文件。注意:如果使用通配符 6,ftw,21 ``` -可以在uri上使用通配符来导入。 +可以在 URI 上使用通配符来导入。 ```sql MySQL [(none)]> select * from s3( @@ -536,10 +532,10 @@ MySQL [(none)]> select * from s3( +------+------+------+ ``` -**配合 `insert into` 和 `cast` 使用 `S3` tvf** +**配合 `insert into` 和 `cast` 使用 `S3` TVF** ```sql -// 创建doris内部表 +// 创建 Doris 内部表 CREATE TABLE IF NOT EXISTS ${testTable} ( id int, @@ -550,7 +546,7 @@ CREATE TABLE IF NOT EXISTS ${testTable} DISTRIBUTED BY HASH(id) BUCKETS 32 PROPERTIES("replication_num" = "1"); -// 使用S3插入数据 +// 使用 S3 插入数据 insert into ${testTable} (id,name,age) select cast (id as INT) as id, name, cast (age as INT) as age from s3( diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md index 9e65320f3dc..ea8e6343ad9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md @@ -26,17 +26,9 @@ under the License. ## HDFS -### Name - -<version since="1.2"> - -hdfs - -</version> - ### Description -HDFS表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 +HDFS 表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 #### syntax ```sql @@ -52,10 +44,10 @@ hdfs( **参数说明** -访问hdfs相关参数: -- `uri`:(必填) 访问hdfs的uri。如果uri路径不存在或文件都是空文件,hdfs tvf将返回空集合。 +访问 HDFS 相关参数: +- `uri`:(必填)访问 HDFS 的 uri。如果 uri 路径不存在或文件都是空文件,HDFS TVF 将返回空集合。 - `fs.defaultFS`:(必填) -- `hadoop.username`: (必填)可以是任意字符串,但不能为空 +- `hadoop.username`:(必填)可以是任意字符串,但不能为空 - `hadoop.security.authentication`:(选填) - `hadoop.username`:(选填) - `hadoop.kerberos.principal`:(选填) @@ -69,13 +61,13 @@ hdfs( - `dfs.namenode.rpc-address.your-nameservices.your-namenode`:(选填) - `dfs.client.failover.proxy.provider.your-nameservices`:(选填) -文件格式相关参数 +文件格式相关参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`:(选填) 列分割符, 默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 -- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。 默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 +- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 - 下面6个参数是用于json格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) + 下面 6 个参数是用于 JSON 格式的导入,具体使用方法可以参照:[JSON Load](../../../data-operate/import/import-way/load-json-format.md) - `read_json_by_line`: (选填) 默认为 `"true"` - `strip_outer_array`: (选填) 默认为 `"false"` @@ -84,17 +76,18 @@ hdfs( - `num_as_string`: (选填) 默认为 `false` - `fuzzy_parse`: (选填) 默认为 `false` - <version since="dev">下面2个参数是用于csv格式的导入</version> + 下面 2 个参数用于 CSV 格式的导入: -- `trim_double_quotes`: 布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 csv 文件每个字段最外层的双引号 -- `skip_lines`: 整数类型,选填,默认值为0,含义为跳过csv文件的前几行。当设置format设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 +- `trim_double_quotes`:布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 CSV 文件每个字段最外层的双引号 +- `skip_lines`:整数类型,选填,默认值为 0,含义为跳过 CSV 文件的前几行。当设置 Format 设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 其他参数: - `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 +- `resource`:(选填)指定 Resource 名,HDFS TVF 可以利用已有的 HFDS Resource 来直接访问 HDFS。创建 HDFS Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 ### Examples -读取并访问 HDFS 存储上的csv格式文件 +读取并访问 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -112,7 +105,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -读取并访问 HA 模式的 HDFS 存储上的csv格式文件 +读取并访问 HA 模式的 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -135,7 +128,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -可以配合`desc function`使用 +可以配合 `desc function` 使用。 ```sql MySQL [(none)]> desc function hdfs( @@ -147,8 +140,8 @@ MySQL [(none)]> desc function hdfs( ### Keywords - hdfs, table-valued-function, tvf + HDFS, table-valued-function, TVF ### Best Practice - 关于HDFS tvf的更详细使用方法可以参照 [S3](./s3.md) tvf, 唯一不同的是访问存储系统的方式不一样。 + 关于 HDFS TVF 的更详细使用方法可以参照 [S3](./s3.md) TVF, 唯一不同的是访问存储系统的方式不一样。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md index ae4b3d106b7..9c5288fc09c 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md @@ -72,7 +72,7 @@ S3 tvf 中的每一个参数都是一个 `"key"="value"` 对。 文件格式参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`:(选填) 列分割符,默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 - `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md index 4ea148cf58f..ea8e6343ad9 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md @@ -26,17 +26,9 @@ under the License. ## HDFS -### Name - -<version since="1.2"> - -hdfs - -</version> - ### Description -HDFS表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 +HDFS 表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 HDFS 上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 #### syntax ```sql @@ -52,10 +44,10 @@ hdfs( **参数说明** -访问hdfs相关参数: -- `uri`:(必填) 访问hdfs的uri。如果uri路径不存在或文件都是空文件,hdfs tvf将返回空集合。 +访问 HDFS 相关参数: +- `uri`:(必填)访问 HDFS 的 uri。如果 uri 路径不存在或文件都是空文件,HDFS TVF 将返回空集合。 - `fs.defaultFS`:(必填) -- `hadoop.username`: (必填)可以是任意字符串,但不能为空 +- `hadoop.username`:(必填)可以是任意字符串,但不能为空 - `hadoop.security.authentication`:(选填) - `hadoop.username`:(选填) - `hadoop.kerberos.principal`:(选填) @@ -69,13 +61,13 @@ hdfs( - `dfs.namenode.rpc-address.your-nameservices.your-namenode`:(选填) - `dfs.client.failover.proxy.provider.your-nameservices`:(选填) -文件格式相关参数 +文件格式相关参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`:(选填) 列分割符, 默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 -- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。 默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 +- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 - 下面6个参数是用于json格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) + 下面 6 个参数是用于 JSON 格式的导入,具体使用方法可以参照:[JSON Load](../../../data-operate/import/import-way/load-json-format.md) - `read_json_by_line`: (选填) 默认为 `"true"` - `strip_outer_array`: (选填) 默认为 `"false"` @@ -84,18 +76,18 @@ hdfs( - `num_as_string`: (选填) 默认为 `false` - `fuzzy_parse`: (选填) 默认为 `false` - <version since="dev">下面2个参数是用于csv格式的导入</version> + 下面 2 个参数用于 CSV 格式的导入: -- `trim_double_quotes`: 布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 csv 文件每个字段最外层的双引号 -- `skip_lines`: 整数类型,选填,默认值为0,含义为跳过csv文件的前几行。当设置format设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 +- `trim_double_quotes`:布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 CSV 文件每个字段最外层的双引号 +- `skip_lines`:整数类型,选填,默认值为 0,含义为跳过 CSV 文件的前几行。当设置 Format 设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 其他参数: - `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定resource名,hdfs tvf 可以利用已有的 hdfs resource 来直接访问hdfs。创建 hdfs resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `resource`:(选填)指定 Resource 名,HDFS TVF 可以利用已有的 HFDS Resource 来直接访问 HDFS。创建 HDFS Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 ### Examples -读取并访问 HDFS 存储上的csv格式文件 +读取并访问 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -113,7 +105,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -读取并访问 HA 模式的 HDFS 存储上的csv格式文件 +读取并访问 HA 模式的 HDFS 存储上的 CSV 格式文件 ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", @@ -136,7 +128,7 @@ MySQL [(none)]> select * from hdfs( +------+---------+------+ ``` -可以配合`desc function`使用 +可以配合 `desc function` 使用。 ```sql MySQL [(none)]> desc function hdfs( @@ -148,8 +140,8 @@ MySQL [(none)]> desc function hdfs( ### Keywords - hdfs, table-valued-function, tvf + HDFS, table-valued-function, TVF ### Best Practice - 关于HDFS tvf的更详细使用方法可以参照 [S3](./s3.md) tvf, 唯一不同的是访问存储系统的方式不一样。 + 关于 HDFS TVF 的更详细使用方法可以参照 [S3](./s3.md) TVF, 唯一不同的是访问存储系统的方式不一样。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md index e7ab641ffb5..b5c718d271b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md @@ -28,15 +28,11 @@ under the License. ### Name -<version since="1.2"> - s3 -</version> - ### description -S3表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 S3 兼容的对象存储上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 +S3 表函数(table-valued-function,tvf),可以让用户像访问关系表格式数据一样,读取并访问 S3 兼容的对象存储上的文件内容。目前支持`csv/csv_with_names/csv_with_names_and_types/json/parquet/orc`文件格式。 **语法** @@ -54,22 +50,22 @@ s3( **参数说明** -S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 -访问S3相关参数: -- `uri`: (必填) 访问S3的uri,S3表函数会根据 `use_path_style` 参数来决定是否使用 path style 访问方式,默认为 virtual-hosted style 方式 +S3 TVF 中的每一个参数都是一个 `"key"="value"` 对。 +访问 S3 相关参数: +- `uri`: (必填) 访问 S3 的 URI,S3 表函数会根据 `use_path_style` 参数来决定是否使用 Path Style 访问方式,默认为 Virtual-hosted Style 方式 - `s3.access_key`: (必填) - `s3.secret_key`: (必填) -- `s3.region`: (选填)。如果Minio服务设置了其他的region,那么必填,否则默认使用`us-east-1`。 +- `s3.region`: (选填)。如果 Minio 服务设置了其他的 Region,那么必填,否则默认使用`us-east-1`。 - `s3.session_token`: (选填) -- `use_path_style`:(选填) 默认为`false` 。S3 SDK 默认使用 virtual-hosted style 方式。但某些对象存储系统可能没开启或没支持virtual-hosted style 方式的访问,此时我们可以添加 use_path_style 参数来强制使用 path style 方式。比如 `minio`默认情况下只允许`path style`访问方式,所以在访问minio时要加上`use_path_style=true`。 -- `force_parsing_by_standard_uri`:(选填)默认 `false` 。 我们可以添加 `force_parsing_by_standard_uri` 参数来强制将非标准的 uri 解析为标准 uri。 +- `use_path_style`:(选填) 默认为`false` 。S3 SDK 默认使用 Virtual-hosted Syle 方式。但某些对象存储系统可能没开启或没支持 Virtual-hosted Style 方式的访问,此时我们可以添加 `use_path_style` 参数来强制使用 Path Style 方式。比如 `minio` 默认情况下只允许 `path style` 访问方式,所以在访问 MinIO 时要加上 `use_path_style=true`。 +- `force_parsing_by_standard_uri`:(选填)默认 `false` 。我们可以添加 `force_parsing_by_standard_uri` 参数来强制将非标准的 URI 解析为标准 URI。 > 对于 AWS S3,标准 uri styles 有以下几种: > 1. AWS Client Style(Hadoop S3 Style): > `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88`。 -> 2. Virtual Host Style:`https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 -> 3. Path Style:`https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 +> 2. Virtual Host Style:`https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 +> 3. Path Style:`https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88`。 > -> 除了支持以上三个标准常见的 uri styles, 还支持其他一些 uri styles(也许不常见,但也有可能有): +> 除了支持以上三个标准常见的 URI Styles, 还支持其他一些 URI Styles(也许不常见,但也有可能有): > 1. Virtual Host AWS Client (Hadoop S3) Mixed Style: > `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 2. Path AWS Client (Hadoop S3) Mixed Style: @@ -79,11 +75,11 @@ S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 文件格式参数: - `format`:(必填) 目前支持 `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`:(选填) 列分割符, 默认为`,`。 +- `column_separator`:(选填) 列分割符,默认为`\t`。 - `line_delimiter`:(选填) 行分割符,默认为`\n`。 -- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。 默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 +- `compress_type`: (选填) 目前支持 `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`。默认值为 `UNKNOWN`, 将会根据 `uri` 的后缀自动推断类型。 -下面6个参数是用于json格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) +下面 6 个参数是用于 JSON 格式的导入,具体使用方法可以参照:[Json Load](../../../data-operate/import/import-way/load-json-format.md) - `read_json_by_line`: (选填) 默认为 `"true"` - `strip_outer_array`: (选填) 默认为 `"false"` @@ -92,18 +88,18 @@ S3 tvf中的每一个参数都是一个 `"key"="value"` 对。 - `num_as_string`: (选填) 默认为 `false` - `fuzzy_parse`: (选填) 默认为 `false` -下面2个参数是用于csv格式的导入 +下面 2 个参数是用于 CSV 格式的导入 -- `trim_double_quotes`: 布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 csv 文件每个字段最外层的双引号 -- `skip_lines`: 整数类型,选填,默认值为0,含义为跳过csv文件的前几行。当设置format设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 +- `trim_double_quotes`:布尔类型,选填,默认值为 `false`,为 `true` 时表示裁剪掉 CSV 文件每个字段最外层的双引号 +- `skip_lines`:整数类型,选填,默认值为 0,含义为跳过 CSV 文件的前几行。当设置 format 设置为 `csv_with_names` 或 `csv_with_names_and_types` 时,该参数会失效 其他参数: -- `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如/path/to/city=beijing/date="2023-07-09", 则填写`path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 -- `resource`:(选填)指定resource名,hdfs tvf 可以利用已有的 hdfs resource 来直接访问hdfs。创建 hdfs resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 +- `path_partition_keys`:(选填)指定文件路径中携带的分区列名,例如 `/path/to/city=beijing/date="2023-07-09"`, 则填写 `path_partition_keys="city,date"`,将会自动从路径中读取相应列名和列值进行导入。 +- `resource`:(选填)指定 Resource 名,S3 TVF 可以利用已有的 S3 Resource 来直接访问 S3。创建 S3 Resource 的方法可以参照 [CREATE-RESOURCE](../../sql-statements/Data-Definition-Statements/Create/CREATE-RESOURCE.md)。该功能自 2.1.4 版本开始支持。 ### Example -读取并访问 S3 兼容的对象存储上的csv格式文件 +读取并访问 S3 兼容的对象存储上的 CSV 格式文件 ```sql select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -114,7 +110,7 @@ select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", ``` -可以配合`desc function`使用 +可以配合 `desc function` 使用 ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -126,15 +122,15 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c ### Keywords - s3, table-valued-function, tvf + S3, table-valued-function, TVF ### Best Practice -**不同url schema的写法** +**不同 url schema 的写法** http:// 、https:// 使用示例: ```sql -// 注意URI bucket写法以及use_path_style参数设置,http同理。 -// 由于设置了"use_path_style"="true", 所以将采用path style方式访问s3。 +// 注意URI Bucket写法以及`use_path_style`参数设置,HTTP 同理。 +// 由于设置了 `"use_path_style"="true"`, 所以将采用 Path Style 的方式访问 S3。 select * from s3( "uri" = "https://endpoint/bucket/file/student.csv", "s3.access_key"= "ak", @@ -142,8 +138,8 @@ select * from s3( "format" = "csv", "use_path_style"="true"); -// 注意URI bucket写法以及use_path_style参数设置,http同理。 -// 由于设置了"use_path_style"="false", 所以将采用virtual-hosted style方式访问s3。 +// 注意 URI Bucket写法以及use_path_style参数设置,http同理。 +// 由于设置了 `"use_path_style"="false"`, 所以将采用 Virtual-hosted Style 方式访问 S3。 select * from s3( "uri" = "https://bucket.endpoint/bucket/file/student.csv", "s3.access_key"= "ak", @@ -151,7 +147,7 @@ select * from s3( "format" = "csv", "use_path_style"="false"); -// 阿里云oss和腾讯云cos采用virtual-hosted style方式访问s3。 +// 阿里云 OSS 和腾讯云 COS 采用 Virtual-hosted Style 方式访问 S3。 // OSS select * from s3( "uri" = "http://example-bucket.oss-cn-beijing.aliyuncs.com/your-folder/file.parquet", @@ -179,7 +175,7 @@ select * from s3( "format" = "csv" ); -// 百度云bos采用兼容s3协议的virtual-hosted style方式访问s3。 +// 百度云 BOS 采用兼容 S3 协议的 Virtual-hosted Style 方式访问 S3。 // BOS select * from s3( "uri" = "https://example-bucket.s3.bj.bcebos.com/your-folder/file.parquet", @@ -193,8 +189,8 @@ select * from s3( s3:// 使用示例: ```sql -// 注意URI bucket写法, 无需设置use_path_style参数。 -// 将采用virtual-hosted style方式访问s3。 +// 注意 URI Bucket 写法, 无需设置 `use_path_style` 参数。 +// 将采用 Virtual-hosted Style 方式访问 S3。 select * from s3( "uri" = "s3://bucket/file/student.csv", "s3.endpoint"= "endpont", @@ -204,7 +200,7 @@ select * from s3( "format" = "csv"); ``` -其它支持的 uri 风格示例: +其它支持的 URI 风格示例: ```sql // Virtual Host AWS Client (Hadoop S3) Mixed Style。通过设置 `use_path_style = false` 以及 `force_parsing_by_standard_uri = true` 来使用。 @@ -227,12 +223,12 @@ select * from s3( ``` -**csv format** -由于S3 table-valued-function事先并不知道table schema,所以会先读一遍文件来解析出table schema。 +**CSV format** +由于 S3 table-valued-function 事先并不知道 Table Schema,所以会先读一遍文件来解析出 Table Schema。 -`csv` 格式: S3 table-valued-function 读取S3上的文件并当作csv文件来处理,读取文件中的第一行用于解析table schema。文件第一行的列个数`n`将作为table schema的列个数,table schema的列名则自动取名为`c1, c2, ..., cn` ,列类型都设置为 `String`, 举例: +`csv` 格式:S3 table-valued-function 读取 S3 上的文件并当作 CSV 文件来处理,读取文件中的第一行用于解析 Table Schema。文件第一行的列个数 `n` 将作为 Table Schema 的列个数,Table Schema 的列名则自动取名为 `c1, c2, ..., cn` ,列类型都设置为 `String`, 举例: -student1.csv文件内容为: +student1.csv 文件内容为: ``` 1,ftw,12 @@ -240,7 +236,7 @@ student1.csv文件内容为: 3,ww,20 ``` -使用S3 tvf +使用 S3 TVF ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -257,7 +253,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.c +------+------+------+ ``` -可以配合 `desc function S3()` 来查看table schema +可以配合 `desc function S3()` 来查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv", @@ -275,9 +271,9 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c ``` **csv_with_names format** -`csv_with_names`格式:解析文件的第一行作为table schema的列个数和列名,列类型则都设置为 `String`, 举例: +`csv_with_names` 格式:解析文件的第一行作为 Table Schema 的列个数和列名,列类型则都设置为 `String`, 举例: -student_with_names.csv文件内容为 +student_with_names.csv 文件内容为 ``` id,name,age @@ -286,7 +282,7 @@ id,name,age 3,ww,20 ``` -使用S3 tvf +使用 S3 tvf ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv", @@ -303,7 +299,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_wi +------+------+------+ ``` -同样配合`desc function S3()` 可查看table schema +同样配合 `desc function S3()` 可查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv", @@ -322,9 +318,9 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi **csv_with_names_and_types foramt** -`csv_with_names_and_types`格式:目前暂不支持从csv文件中解析出column type。使用该format时,S3 tvf会解析文件的第一行作为table schema的列个数和列名,列类型则都设置为 String,同时将忽略该文件的第二行。 +`csv_with_names_and_types` 格式:目前暂不支持从 CSV 文件中解析出 Column Type。使用该 Format 时,S3 TVF 会解析文件的第一行作为 Table Schema 的列个数和列名,列类型则都设置为 String,同时将忽略该文件的第二行。 -student_with_names_and_types.csv文件内容为 +`student_with_names_and_types.csv` 文件内容为 ``` id,name,age @@ -334,7 +330,7 @@ INT,STRING,INT 3,ww,20 ``` -使用S3 tvf +使用 S3 TVF ```sql MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv", @@ -351,7 +347,7 @@ MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_wi +------+------+------+ ``` -同样配合`desc function S3()` 可查看table schema +同样配合 `desc function S3()` 可查看 Table Schema ```sql MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv", @@ -368,11 +364,11 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi +-------+------+------+-------+---------+-------+ ``` -**json format** +**JSON format** -`json` 格式:json格式涉及到较多的可选参数,各个参数的意义可以参考:[Json Load](../../../data-operate/import/import-way/load-json-format.md)。 S3 tvf查询json格式文件时根据 `json_root` 和 `jsonpaths` 参数定位到一个json对象,将该对象的中的`key` 作为table schema的列名,列类型都设置为String。举例: +`json` 格式:JSON 格式涉及到较多的可选参数,各个参数的意义可以参考:[Json Load](../../../data-operate/import/import-way/load-json-format.md)。S3 TVF 查询 JSON 格式文件时根据 `json_root` 和 `jsonpaths` 参数定位到一个 JSON 对象,将该对象的中的 `key` 作为 Table Schema 的列名,列类型都设置为 String。举例: -data.json文件 +data.json 文件 ``` [{"id":1, "name":"ftw", "age":18}] @@ -380,7 +376,7 @@ data.json文件 [{"id":3, "name":"yyy", "age":19}] ``` -使用S3 tvf查询 +使用 S3 TVF 查询 ```sql MySQL [(none)]> select * from s3( @@ -416,9 +412,9 @@ MySQL [(none)]> select * from s3( +------+------+ ``` -**parquet format** +**Parquet format** -`parquet` 格式:S3 tvf支持从parquet文件中解析出table schema的列名、列类型。举例: +`parquet` 格式:S3 TVF 支持从 Parquet 文件中解析出 Table Schema 的列名、列类型。举例: ```sql MySQL [(none)]> select * from s3( @@ -462,7 +458,7 @@ MySQL [(none)]> desc function s3( **orc format** -`orc` 格式:和`parquet` format使用方法一致, 将`format`参数设置为orc。 +`orc` 格式:和 `parquet` format 使用方法一致,将 `format` 参数设置为 `orc`。 ```sql MySQL [(none)]> select * from s3( @@ -483,7 +479,7 @@ MySQL [(none)]> select * from s3( ``` **avro format** -`avro` 格式:S3 tvf支持从avro文件中解析出table schema的列名、列类型。举例: +`avro` 格式:S3 TVF 支持从 avro 文件中解析出 Table Schema 的列名、列类型。举例: ```sql select * from s3( @@ -500,10 +496,10 @@ select * from s3( +--------+--------------+-------------+-----------------+ ``` -**uri包含通配符** +**URI 包含通配符** -uri可以使用通配符来读取多个文件。注意:如果使用通配符要保证各个文件的格式是一致的(尤其是csv/csv_with_names/csv_with_names_and_types算做不同的格式),S3 tvf用第一个文件来解析出table schema。 -如下两个csv文件: +URI 可以使用通配符来读取多个文件。注意:如果使用通配符要保证各个文件的格式是一致的 (尤其是 `csv`/`csv_with_names`/`csv_with_names_and_types` 算做不同的格式),S3 TVF 用第一个文件来解析出 Table Schema。 +如下两个 CSV 文件: ``` // file1.csv @@ -516,7 +512,7 @@ uri可以使用通配符来读取多个文件。注意:如果使用通配符 6,ftw,21 ``` -可以在uri上使用通配符来导入。 +可以在 URI 上使用通配符来导入。 ```sql MySQL [(none)]> select * from s3( @@ -536,10 +532,10 @@ MySQL [(none)]> select * from s3( +------+------+------+ ``` -**配合 `insert into` 和 `cast` 使用 `S3` tvf** +**配合 `insert into` 和 `cast` 使用 `S3` TVF** ```sql -// 创建doris内部表 +// 创建 Doris 内部表 CREATE TABLE IF NOT EXISTS ${testTable} ( id int, @@ -550,7 +546,7 @@ CREATE TABLE IF NOT EXISTS ${testTable} DISTRIBUTED BY HASH(id) BUCKETS 32 PROPERTIES("replication_num" = "1"); -// 使用S3插入数据 +// 使用 S3 插入数据 insert into ${testTable} (id,name,age) select cast (id as INT) as id, name, cast (age as INT) as age from s3( diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md b/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md index 3b73028086c..e75ab1a2df3 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/hdfs.md @@ -62,6 +62,7 @@ Related parameters for accessing hdfs: - `dfs.domain.socket.path`: (optional) Related parameters for accessing HDFS in HA mode: + - `dfs.nameservices`: (optional) - `dfs.ha.namenodes.your-nameservices`: (optional) - `dfs.namenode.rpc-address.your-nameservices.your-namenode`: (optional) @@ -70,7 +71,7 @@ Related parameters for accessing HDFS in HA mode: File format parameters: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -114,6 +115,7 @@ MySQL [(none)]> select * from hdfs( ``` Read and access csv format files on hdfs storage in HA mode. + ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", diff --git a/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md b/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md index dbf049ffca0..3f141ab5dd3 100644 --- a/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md +++ b/versioned_docs/version-2.0/sql-manual/sql-functions/table-functions/s3.md @@ -27,6 +27,7 @@ under the License. ## S3 ### Name + S3 ### description @@ -61,6 +62,7 @@ Related parameters for accessing S3: - `use_path_style`: (optional) default `false` . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the `use_path_style` parameter to force the use of path style access method. > Note: URI currently supports three SCHEMA: http://, https:// and s3://. +> > 1. If you use http:// or https://, you will decide whether to use the 'path > style' to access s3 based on the 'use_path_style' parameter > 2. If you use s3://, you will use the "virtual-hosted style' to access the > s3, 'use_path_style' parameter is invalid. > 3. If the uri path does not exist or the files are empty files, s3 tvf will > return an empty result set. @@ -70,7 +72,7 @@ Related parameters for accessing S3: file format parameter: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -119,7 +121,8 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c s3, table-valued-function, tvf ### Best Practice -Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. + +Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. **Usage of different uri schemas** Example of http:// , https:// @@ -174,10 +177,8 @@ select * from s3( "format" = "csv"); ``` - **csv format** `csv` format: Read the file on S3 and process it as a csv file, read the first line in the file to parse out the table schema. The number of columns in the first line of the file `n` will be used as the number of columns in the table schema, and the column names of the table schema will be automatically named `c1, c2, ..., cn`, and the column type is set to `String` , for example: - The file content of student1.csv: @@ -264,7 +265,7 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi | age | TEXT | Yes | false | NULL | NONE | +-------+------+------+-------+---------+-------+ ``` - + **csv_with_names_and_types format** `csv_with_names_and_types` format: Currently, it does not support parsing the column type from a csv file. When using this format, S3 tvf will parse the first line of the file as the number and name of the columns of the table schema, and set the column type to String. Meanwhile, the second line of the file is ignored. diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md index 7a281e06c60..61c19aa0ff6 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/hdfs.md @@ -62,6 +62,7 @@ Related parameters for accessing hdfs: - `dfs.domain.socket.path`: (optional) Related parameters for accessing HDFS in HA mode: + - `dfs.nameservices`: (optional) - `dfs.ha.namenodes.your-nameservices`: (optional) - `dfs.namenode.rpc-address.your-nameservices.your-namenode`: (optional) @@ -70,7 +71,7 @@ Related parameters for accessing HDFS in HA mode: File format parameters: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc/avro` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -115,6 +116,7 @@ MySQL [(none)]> select * from hdfs( ``` Read and access csv format files on hdfs storage in HA mode. + ```sql MySQL [(none)]> select * from hdfs( "uri" = "hdfs://127.0.0.1:842/user/doris/csv_format_test/student.csv", diff --git a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md b/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md index 5d7e25816c3..05f62a13fd1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md +++ b/versioned_docs/version-2.1/sql-manual/sql-functions/table-functions/s3.md @@ -27,6 +27,7 @@ under the License. ## S3 ### Name + S3 ### description @@ -61,13 +62,15 @@ Related parameters for accessing S3: - `use_path_style`: (optional) default `false` . The S3 SDK uses the virtual-hosted style by default. However, some object storage systems may not be enabled or support virtual-hosted style access. At this time, we can add the `use_path_style` parameter to force the use of path style access method. - `force_parsing_by_standard_uri`: (optional) default `false` . We can add `force_parsing_by_standard_uri` parameter to force parsing unstandard uri as standard uri. -> Note: +> Note: > For AWS S3, standard uri styles should be: +> > 1. AWS Client Style(Hadoop S3 Style): > `s3://my-bucket/path/to/file?versionId=abc123&partNumber=77&partNumber=88` > 2. Virtual Host Style: > `https://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 3. Path Style: > `https://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > > In addition to supporting the common uri styles of the above three > standards, it also supports some other uri styles (maybe not common, but > there may be): +> > 1. Virtual Host AWS Client (Hadoop S3) Mixed Style: > `s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88` > 2. Path AWS Client (Hadoop S3) Mixed Style: @@ -78,7 +81,7 @@ Related parameters for accessing S3: file format parameter: - `format`: (required) Currently support `csv/csv_with_names/csv_with_names_and_types/json/parquet/orc` -- `column_separator`: (optional) default `,`. +- `column_separator`: (optional) default `\t`. - `line_delimiter`: (optional) default `\n`. - `compress_type`: (optional) Currently support `UNKNOWN/PLAIN/GZ/LZO/BZ2/LZ4FRAME/DEFLATE/SNAPPYBLOCK`. Default value is `UNKNOWN`, it will automatically infer the type based on the suffix of `uri`. @@ -128,7 +131,8 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.c s3, table-valued-function, tvf ### Best Practice -Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. + +Since the S3 table-valued-function does not know the table schema in advance, it will read the file first to parse out the table schema. **Usage of different uri schemas** Example of http:// 、https:// @@ -184,7 +188,7 @@ select * from s3( // MinIO select * from s3( "uri" = "s3://bucket/file.csv", - "s3.endpoint" = "http://172.21.0.101:9000", + "s3.endpoint" = "<http://172.21.0.101:9000>", "s3.access_key"= "ak", "s3.secret_key" = "sk", "s3.region" = "us-east-1", @@ -227,10 +231,8 @@ select * from s3( "force_parsing_by_standard_uri"="true"); ``` - **csv format** `csv` format: Read the file on S3 and process it as a csv file, read the first line in the file to parse out the table schema. The number of columns in the first line of the file `n` will be used as the number of columns in the table schema, and the column names of the table schema will be automatically named `c1, c2, ..., cn`, and the column type is set to `String` , for example: - The file content of student1.csv: @@ -317,7 +319,7 @@ MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_wi | age | TEXT | Yes | false | NULL | NONE | +-------+------+------+-------+---------+-------+ ``` - + **csv_with_names_and_types format** `csv_with_names_and_types` format: Currently, it does not support parsing the column type from a csv file. When using this format, S3 tvf will parse the first line of the file as the number and name of the columns of the table schema, and set the column type to String. Meanwhile, the second line of the file is ignored. --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org