S3

Name

S3

description

S3 table-valued-function(tvf), allows users to read and access file contents on S3-compatible object storage, just like accessing relational table. Currently supports csv/csv_with_names/csv_with_names_and_types/json/parquet/orc file format.

syntax

  1. s3(
  2. "uri" = "..",
  3. "s3.access_key" = "...",
  4. "s3.secret_key" = "...",
  5. "s3.region" = "...",
  6. "s3.endpoint" = "...",
  7. "format" = "csv",
  8. "keyn" = "valuen",
  9. ...
  10. );

parameter description

Each parameter in S3 tvf is a pair of "key"="value".

Related parameters for accessing S3:

  • uri: (required) The S3 tvf will decide whether to use the path style access method according to the use_path_style parameter, and the default access method is the virtual-hosted style method.
  • s3.access_key: (required)
  • s3.secret_key: (required)
  • s3.region: (required)
  • s3.endpoint:(required)
  • s3.session_token: (optional)
  • 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: 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: s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88

For detailed use cases, you can refer to Best Practice at the bottom.

file format parameter:

  • format: (required) Currently support csv/csv_with_names/csv_with_names_and_types/json/parquet/orc
  • 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.

The following 6 parameters are used for loading in json format. For specific usage methods, please refer to: Json Load

  • read_json_by_line: (optional) default "true"
  • strip_outer_array: (optional) default "false"
  • json_root: (optional) default ""
  • jsonpaths: (optional) default ""
  • num_as_string: (optional) default "false"
  • fuzzy_parse: (optional) default "false"

The following 2 parameters are used for loading in csv format

  • trim_double_quotes: Boolean type (optional), the default value is false. True means that the outermost double quotes of each field in the csv file are trimmed.
  • skip_lines: Integer type (optional), the default value is 0. It will skip some lines in the head of csv file. It will be disabled when the format is csv_with_names or csv_with_names_and_types.

other parameter:

  • path_partition_keys: (optional) Specifies the column names carried in the file path. For example, if the file path is /path/to/city=beijing/date=”2023-07-09”, you should fill in path_partition_keys="city,date". It will automatically read the corresponding column names and values from the path during load process.
  • resource:(optional)Specify the resource name. S3 tvf can use the existing S3 resource to directly access S3. You can refer to the method for creating an S3 resource: CREATE-RESOURCE. This property is supported starting from version 2.1.4 .

S3 - 图1Tip

To directly query a TVF or create a VIEW based on that TVF, you need to have usage permission for that resource. To query a VIEW created based on TVF, you only need select permission for that VIEW.

Example

Read and access csv format files on S3-compatible object storage.

  1. select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv",
  2. "s3.access_key"= "minioadmin",
  3. "s3.secret_key" = "minioadmin",
  4. "s3.endpoint" = "http://127.0.0.1:9312",
  5. "s3.region" = "us-east-1",
  6. "format" = "csv",
  7. "use_path_style" = "true") order by c1;

Can be used with desc function

  1. MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv",
  2. "s3.access_key"= "minioadmin",
  3. "s3.secret_key" = "minioadmin",
  4. "s3.endpoint" = "http://127.0.0.1:9312",
  5. "s3.region" = "us-east-1",
  6. "format" = "csv",
  7. "use_path_style" = "true");

Keywords

  1. 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.

Usage of different uri schemas Example of http:// 、https://

  1. // Note how to write your bucket of URI and set the 'use_path_style' parameter, as well as http://.
  2. // Because of "use_path_style"="true", s3 will be accessed in 'path style'.
  3. select * from s3(
  4. "URI" = "https://endpoint/bucket/file/student.csv",
  5. "s3.access_key"= "ak",
  6. "s3.secret_key" = "sk",
  7. "s3.endpoint" = "endpoint",
  8. "s3.region" = "region",
  9. "format" = "csv",
  10. "use_path_style"="true");
  11. // Note how to write your bucket of URI and set the 'use_path_style' parameter, as well as http://.
  12. // Because of "use_path_style"="false", s3 will be accessed in 'virtual-hosted style'.
  13. select * from s3(
  14. "URI" = "https://bucket.endpoint/file/student.csv",
  15. "s3.access_key"= "ak",
  16. "s3.secret_key" = "sk",
  17. "s3.endpoint" = "endpoint",
  18. "s3.region" = "region",
  19. "format" = "csv",
  20. "use_path_style"="false");
  21. // The OSS on Alibaba Cloud and The COS on Tencent Cloud will use 'virtual-hosted style' to access s3.
  22. // OSS
  23. select * from s3(
  24. "URI" = "http://example-bucket.oss-cn-beijing.aliyuncs.com/your-folder/file.parquet",
  25. "s3.access_key" = "ak",
  26. "s3.secret_key" = "sk",
  27. "s3.endpoint" = "oss-cn-beijing.aliyuncs.com",
  28. "s3.region" = "oss-cn-beijing",
  29. "format" = "parquet",
  30. "use_path_style" = "false");
  31. // COS
  32. select * from s3(
  33. "URI" = "https://example-bucket.cos.ap-hongkong.myqcloud.com/your-folder/file.parquet",
  34. "s3.access_key" = "ak",
  35. "s3.secret_key" = "sk",
  36. "s3.endpoint" = "cos.ap-hongkong.myqcloud.com",
  37. "s3.region" = "ap-hongkong",
  38. "format" = "parquet",
  39. "use_path_style" = "false");
  40. // MinIO
  41. select * from s3(
  42. "uri" = "s3://bucket/file.csv",
  43. "s3.endpoint" = "http://172.21.0.101:9000",
  44. "s3.access_key"= "ak",
  45. "s3.secret_key" = "sk",
  46. "s3.region" = "us-east-1",
  47. "format" = "csv"
  48. );
  49. // The BOS on Baidu Cloud will use 'virtual-hosted style' compatible with the S3 protocol to access s3.
  50. // BOS
  51. select * from s3(
  52. "uri" = "https://example-bucket.s3.bj.bcebos.com/your-folder/file.parquet",
  53. "s3.access_key"= "ak",
  54. "s3.secret_key" = "sk",
  55. "s3.region" = "bj",
  56. "s3.endpoint" = "http://bj.bcebos.com",
  57. "format" = "parquet",
  58. "use_path_style" = "false");

Example of s3://:

  1. // Note how to write your bucket of URI, no need to set 'use_path_style'.
  2. // s3 will be accessed in 'virtual-hosted style'.
  3. select * from s3(
  4. "URI" = "s3://bucket/file/student.csv",
  5. "s3.endpoint"= "endpont",
  6. "s3.region" = "region",
  7. "s3.access_key"= "ak",
  8. "s3.secret_key" = "sk",
  9. "format" = "csv");

Example of other uri styles:

  1. // Virtual Host AWS Client (Hadoop S3) Mixed Style. Used by setting `use_path_style = false` and `force_parsing_by_standard_uri = true`.
  2. select * from s3(
  3. "URI" = "s3://my-bucket.s3.us-west-1.amazonaws.com/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88",
  4. "s3.access_key"= "ak",
  5. "s3.secret_key" = "sk",
  6. "s3.endpoint"= "endpont",
  7. "s3.region"= "region",
  8. "format" = "csv",
  9. "use_path_style"="false",
  10. "force_parsing_by_standard_uri"="true");
  11. // Path AWS Client (Hadoop S3) Mixed Style. Used by setting `use_path_style = true` and `force_parsing_by_standard_uri = true`.
  12. select * from s3(
  13. "URI" = "s3://s3.us-west-1.amazonaws.com/my-bucket/resources/doc.txt?versionId=abc123&partNumber=77&partNumber=88",
  14. "s3.access_key"= "ak",
  15. "s3.secret_key" = "sk",
  16. "s3.endpoint"= "endpont",
  17. "s3.region"= "region",
  18. "format" = "csv",
  19. "use_path_style"="true",
  20. "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:

  1. 1,ftw,12
  2. 2,zs,18
  3. 3,ww,20

use S3 tvf

  1. MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student1.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv",
  7. -> "use_path_style" = "true") order by c1;
  8. +------+------+------+
  9. | c1 | c2 | c3 |
  10. +------+------+------+
  11. | 1 | ftw | 12 |
  12. | 2 | zs | 18 |
  13. | 3 | ww | 20 |
  14. +------+------+------+

use desc function S3() to view the table schema

  1. MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student1.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv",
  7. -> "use_path_style" = "true");
  8. +-------+------+------+-------+---------+-------+
  9. | Field | Type | Null | Key | Default | Extra |
  10. +-------+------+------+-------+---------+-------+
  11. | c1 | TEXT | Yes | false | NULL | NONE |
  12. | c2 | TEXT | Yes | false | NULL | NONE |
  13. | c3 | TEXT | Yes | false | NULL | NONE |
  14. +-------+------+------+-------+---------+-------+

csv_with_names format csv_with_names format: The first line of the file is used as the number and name of the columns of the table schema, and the column type is set to String, for example:

The file content of student_with_names.csv:

  1. id,name,age
  2. 1,ftw,12
  3. 2,zs,18
  4. 3,ww,20

use S3 tvf

  1. MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv_with_names",
  7. -> "use_path_style" = "true") order by id;
  8. +------+------+------+
  9. | id | name | age |
  10. +------+------+------+
  11. | 1 | ftw | 12 |
  12. | 2 | zs | 18 |
  13. | 3 | ww | 20 |
  14. +------+------+------+

You can also use desc function S3() to view the Table Schema.

  1. MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv_with_names",
  7. -> "use_path_style" = "true");
  8. +-------+------+------+-------+---------+-------+
  9. | Field | Type | Null | Key | Default | Extra |
  10. +-------+------+------+-------+---------+-------+
  11. | id | TEXT | Yes | false | NULL | NONE |
  12. | name | TEXT | Yes | false | NULL | NONE |
  13. | age | TEXT | Yes | false | NULL | NONE |
  14. +-------+------+------+-------+---------+-------+

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.

The file content of student_with_names_and_types.csv:

  1. id,name,age
  2. INT,STRING,INT
  3. 1,ftw,12
  4. 2,zs,18
  5. 3,ww,20

use S3 tvf

  1. MySQL [(none)]> select * from s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv_with_names_and_types",
  7. -> "use_path_style" = "true") order by id;
  8. +------+------+------+
  9. | id | name | age |
  10. +------+------+------+
  11. | 1 | ftw | 12 |
  12. | 2 | zs | 18 |
  13. | 3 | ww | 20 |
  14. +------+------+------+

You can also use desc function S3() to view the Table Schema.

  1. MySQL [(none)]> Desc function s3("uri" = "http://127.0.0.1:9312/test2/student_with_names_and_types.csv",
  2. -> "s3.access_key"= "minioadmin",
  3. -> "s3.secret_key" = "minioadmin",
  4. -> "s3.endpoint" = "http://127.0.0.1:9312",
  5. -> "s3.region" = "us-east-1",
  6. -> "format" = "csv_with_names_and_types",
  7. -> "use_path_style" = "true");
  8. +-------+------+------+-------+---------+-------+
  9. | Field | Type | Null | Key | Default | Extra |
  10. +-------+------+------+-------+---------+-------+
  11. | id | TEXT | Yes | false | NULL | NONE |
  12. | name | TEXT | Yes | false | NULL | NONE |
  13. | age | TEXT | Yes | false | NULL | NONE |
  14. +-------+------+------+-------+---------+-------+

json format

json format: The json format involves many optional parameters, and the meaning of each parameter can be referred to: Json Load. When S3 tvf queries the json format file, it locates a json object according to the json_root and jsonpaths parameters, and uses the key in the object as the column name of the table schema, and sets the column type to String. For example:

The file content of data.json:

  1. [{"id":1, "name":"ftw", "age":18}]
  2. [{"id":2, "name":"xxx", "age":17}]
  3. [{"id":3, "name":"yyy", "age":19}]

use S3 tvf:

  1. MySQL [(none)]> select * from s3(
  2. "uri" = "http://127.0.0.1:9312/test2/data.json",
  3. "s3.access_key"= "minioadmin",
  4. "s3.secret_key" = "minioadmin",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "format" = "json",
  8. "strip_outer_array" = "true",
  9. "read_json_by_line" = "true",
  10. "use_path_style"="true");
  11. +------+------+------+
  12. | id | name | age |
  13. +------+------+------+
  14. | 1 | ftw | 18 |
  15. | 2 | xxx | 17 |
  16. | 3 | yyy | 19 |
  17. +------+------+------+
  18. MySQL [(none)]> select * from s3(
  19. "uri" = "http://127.0.0.1:9312/test2/data.json",
  20. "s3.access_key"= "minioadmin",
  21. "s3.secret_key" = "minioadmin",
  22. "s3.endpoint" = "http://127.0.0.1:9312",
  23. "s3.region" = "us-east-1",
  24. "format" = "json",
  25. "strip_outer_array" = "true",
  26. "jsonpaths" = "[\"$.id\", \"$.age\"]",
  27. "use_path_style"="true");
  28. +------+------+
  29. | id | age |
  30. +------+------+
  31. | 1 | 18 |
  32. | 2 | 17 |
  33. | 3 | 19 |
  34. +------+------+

parquet format

parquet format: S3 tvf supports parsing the column names and column types of the table schema from the parquet file. Example:

  1. MySQL [(none)]> select * from s3(
  2. "uri" = "http://127.0.0.1:9312/test2/test.snappy.parquet",
  3. "s3.access_key"= "minioadmin",
  4. "s3.secret_key" = "minioadmin",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "format" = "parquet",
  8. "use_path_style"="true") limit 5;
  9. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
  10. | p_partkey | p_name | p_mfgr | p_brand | p_type | p_size | p_container | p_retailprice | p_comment |
  11. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
  12. | 1 | goldenrod lavender spring chocolate lace | Manufacturer#1 | Brand#13 | PROMO BURNISHED COPPER | 7 | JUMBO PKG | 901 | ly. slyly ironi |
  13. | 2 | blush thistle blue yellow saddle | Manufacturer#1 | Brand#13 | LARGE BRUSHED BRASS | 1 | LG CASE | 902 | lar accounts amo |
  14. | 3 | spring green yellow purple cornsilk | Manufacturer#4 | Brand#42 | STANDARD POLISHED BRASS | 21 | WRAP CASE | 903 | egular deposits hag |
  15. | 4 | cornflower chocolate smoke green pink | Manufacturer#3 | Brand#34 | SMALL PLATED BRASS | 14 | MED DRUM | 904 | p furiously r |
  16. | 5 | forest brown coral puff cream | Manufacturer#3 | Brand#32 | STANDARD POLISHED TIN | 15 | SM PKG | 905 | wake carefully |
  17. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
  1. MySQL [(none)]> desc function s3(
  2. "uri" = "http://127.0.0.1:9312/test2/test.snappy.parquet",
  3. "s3.access_key"= "minioadmin",
  4. "s3.secret_key" = "minioadmin",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "format" = "parquet",
  8. "use_path_style"="true");
  9. +---------------+--------------+------+-------+---------+-------+
  10. | Field | Type | Null | Key | Default | Extra |
  11. +---------------+--------------+------+-------+---------+-------+
  12. | p_partkey | INT | Yes | false | NULL | NONE |
  13. | p_name | TEXT | Yes | false | NULL | NONE |
  14. | p_mfgr | TEXT | Yes | false | NULL | NONE |
  15. | p_brand | TEXT | Yes | false | NULL | NONE |
  16. | p_type | TEXT | Yes | false | NULL | NONE |
  17. | p_size | INT | Yes | false | NULL | NONE |
  18. | p_container | TEXT | Yes | false | NULL | NONE |
  19. | p_retailprice | DECIMAL(9,0) | Yes | false | NULL | NONE |
  20. | p_comment | TEXT | Yes | false | NULL | NONE |
  21. +---------------+--------------+------+-------+---------+-------+

orc format

orc format: Same as parquet format, set format parameter to orc.

  1. MySQL [(none)]> select * from s3(
  2. "uri" = "http://127.0.0.1:9312/test2/test.snappy.orc",
  3. "s3.access_key"= "minioadmin",
  4. "s3.secret_key" = "minioadmin",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "format" = "orc",
  8. "use_path_style"="true") limit 5;
  9. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
  10. | p_partkey | p_name | p_mfgr | p_brand | p_type | p_size | p_container | p_retailprice | p_comment |
  11. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+
  12. | 1 | goldenrod lavender spring chocolate lace | Manufacturer#1 | Brand#13 | PROMO BURNISHED COPPER | 7 | JUMBO PKG | 901 | ly. slyly ironi |
  13. | 2 | blush thistle blue yellow saddle | Manufacturer#1 | Brand#13 | LARGE BRUSHED BRASS | 1 | LG CASE | 902 | lar accounts amo |
  14. | 3 | spring green yellow purple cornsilk | Manufacturer#4 | Brand#42 | STANDARD POLISHED BRASS | 21 | WRAP CASE | 903 | egular deposits hag |
  15. | 4 | cornflower chocolate smoke green pink | Manufacturer#3 | Brand#34 | SMALL PLATED BRASS | 14 | MED DRUM | 904 | p furiously r |
  16. | 5 | forest brown coral puff cream | Manufacturer#3 | Brand#32 | STANDARD POLISHED TIN | 15 | SM PKG | 905 | wake carefully |
  17. +-----------+------------------------------------------+----------------+----------+-------------------------+--------+-------------+---------------+---------------------+

avro format

avro format: S3 tvf supports parsing the column names and column types of the table schema from the avro file. Example:

  1. select * from s3(
  2. "uri" = "http://127.0.0.1:9312/test2/person.avro",
  3. "ACCESS_KEY" = "ak",
  4. "SECRET_KEY" = "sk",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "FORMAT" = "avro");
  8. +--------+--------------+-------------+-----------------+
  9. | name | boolean_type | double_type | long_type |
  10. +--------+--------------+-------------+-----------------+
  11. | Alyssa | 1 | 10.0012 | 100000000221133 |
  12. | Ben | 0 | 5555.999 | 4009990000 |
  13. | lisi | 0 | 5992225.999 | 9099933330 |
  14. +--------+--------------+-------------+-----------------+

uri contains wildcards

uri can use wildcards to read multiple files. Note: If wildcards are used, the format of each file must be consistent (especially csv/csv_with_names/csv_with_names_and_types count as different formats), S3 tvf uses the first file to parse out the table schema. For example:

The following two csv files:

  1. // file1.csv
  2. 1,aaa,18
  3. 2,qqq,20
  4. 3,qwe,19
  5. // file2.csv
  6. 5,cyx,19
  7. 6,ftw,21

You can use wildcards on the uri to query.

  1. MySQL [(none)]> select * from s3(
  2. "uri" = "http://127.0.0.1:9312/test2/file*.csv",
  3. "s3.access_key"= "minioadmin",
  4. "s3.secret_key" = "minioadmin",
  5. "s3.endpoint" = "http://127.0.0.1:9312",
  6. "s3.region" = "us-east-1",
  7. "format" = "csv",
  8. "use_path_style"="true");
  9. +------+------+------+
  10. | c1 | c2 | c3 |
  11. +------+------+------+
  12. | 1 | aaa | 18 |
  13. | 2 | qqq | 20 |
  14. | 3 | qwe | 19 |
  15. | 5 | cyx | 19 |
  16. | 6 | ftw | 21 |
  17. +------+------+------+

Using S3 tvf with insert into and cast

  1. // Create doris internal table
  2. CREATE TABLE IF NOT EXISTS ${testTable}
  3. (
  4. id int,
  5. name varchar(50),
  6. age int
  7. )
  8. COMMENT "my first table"
  9. DISTRIBUTED BY HASH(id) BUCKETS 32
  10. PROPERTIES("replication_num" = "1");
  11. // Insert data using S3
  12. insert into ${testTable} (id,name,age)
  13. select cast (id as INT) as id, name, cast (age as INT) as age
  14. from s3(
  15. "uri" = "${uri}",
  16. "s3.access_key"= "${ak}",
  17. "s3.secret_key" = "${sk}",
  18. "s3.endpoint" = "http://127.0.0.1:9312",
  19. "s3.region" = "us-east-1",
  20. "format" = "${format}",
  21. "strip_outer_array" = "true",
  22. "read_json_by_line" = "true",
  23. "use_path_style" = "true");