简体   繁体   English

如何使用 Trino 读取位于 s3 上的镶木地板文件?

[英]How read the parquet file located on s3 using Trino?

I`m beginer in the S3 and Trino(Presto).我是 S3 和 Trino(Presto) 的初学者。 I have: installed on-premises Trino(Presto) using Docker. S3 bucket where located files with parquet file exension.我有:使用 Docker 安装本地 Trino(Presto)。S3 存储桶中包含镶木地板文件扩展的文件。 Im install Apache-Drill and in the box he has s3 conector.我安装 Apache-Drill 并且在他的盒子里有 s3 conector。 And in the Apache-Drill a an use并在 Apache-Drill 中使用

SELECT * FROM `s3a`.`root`.`./files.parquet`

to select all from file parquet.到 select 全部来自文件镶木地板。 I thy to do this in Trino(Presto) but i not have result(have error).我想在 Trino(Presto) 中执行此操作,但我没有结果(有错误)。 How i can do same in the Trino(Presto)?我如何在 Trino(Presto)中做同样的事情?

Ps: When i create the external table with option external_location and format parquet - i can select from it. Ps:当我使用选项 external_location 和格式 parquet 创建外部表时 - 我可以从中得到 select。 But do select from exist parquet - i cannot.但是从现有的镶木地板做 select - 我不能。

I`m beginer in the Presto(Trino) and Apache Drill.我是 Presto(Trino)和 Apache Drill 的初学者。 In the situation with Apache Dril and S3 - you can generate file "parquet" and upload to the S3.在 Apache Dril 和 S3 的情况下 - 您可以生成文件“parquet”并上传到 S3。 Then you config the connector(catalog) in the Drill and do something like然后你在 Drill 中配置连接器(目录)并做一些类似的事情

SELECT * FROM `s3a`.`root`.`./filename.parquet` 

This do the select from exists file parquet.这从现有文件 parquet 执行 select。 Apache Drill do scan metadata automaticaly. Apache Drill 自动扫描元数据。 In the example the Trino(Presto) - you config catalog and create schema in the catalog.在示例中的 Trino(Presto) - 您配置目录并在目录中创建模式。 But do the SELECT from file you cannot.但是你不能从文件中执行 SELECT。 You mast create folder on the s3 and upload parquet files in created dir.您必须在 s3 上创建文件夹并在创建的目录中上传镶木地板文件。 In the Presto you must create table with correct metadata and set external_location and format PARQUET pointed to the dir.在 Presto 中,您必须使用正确的元数据创建表并设置 external_location 和格式 PARQUET 指向目录。 After then you can do the select from table which indicate to the dir where located parquet files BUT you can only select columns which you created when created table.之后,您可以从表中执行 select 指示镶木地板文件所在的目录,但您只能在创建表时创建的 select 列。 For example: We have files named userdata.parquet and s3 root access to the backet named "testbucket".例如:我们有名为 userdata.parquet 的文件和对名为“testbucket”的 backet 的 s3 root 访问权限。 The file userdata.parquet has 2 columns (name varchar(20),password varchar(50)) You create on S3 folder usertable and upload in to this folder file userdata.parquet.文件 userdata.parquet 有 2 列(名称 varchar(20),密码 varchar(50))您在 S3 文件夹 usertable 上创建并上传到此文件夹文件 userdata.parquet。 In presto cmd you must create the table:在 presto cmd 中,您必须创建表:

create table users (name varchar(20), password varchar(50)) with (external_location='s3a://testbucket/usertable',format='PARQUET');

Now you cat do in the Presto CLI:现在您可以在 Presto CLI 中执行以下操作:

select * from users;

Or you can create 2 tables:或者您可以创建 2 个表:

create table users1 (name varchar(20)) with (external_location='s3a://testbucket/usertable',format='PARQUET');

create table users2 (password varchar(50)) with (external_location='s3a://testbucket/usertable',format='PARQUET');

And after:之后:

Select * from users1;

select * from users2;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM