1

我正在使用 qubole 运行 presto 查询。

我需要将 csv 文件上传到我的查询中,但无法弄清楚如何执行此操作。

有人对这个有经验么?

有关更多详细信息,我在分析部分下。

在此处输入图像描述

在此处输入图像描述

这是我到目前为止基于@leftjoin 的回答所得到的——

use adhoc;
create external table adhoc.test(
  Media_Buy_Key string,
  Day string,
  DSP_Publisher string,
  Final_Media_Cost string
)
row format delimited
fields terminated by ','
lines terminated by '\n'
location 's3://bucket/folder/folder/file.csv/';

然后我运行配置单元查询,它显示为[Empty]

这是我的 s3 存储桶的样子: 在此处输入图像描述

4

1 回答 1

1

Presto 使用 Hive 元存储来获取表信息及其数据位置。

  1. 将文件上传到某个 S3 位置。实际上,S3 没有位置,它们是使用包含“/”的文件名来模拟的。使用 Qubole S3 接口上传文件。说,到s3://your-bucket-name/your-location/yourfile.csv这里的位置是s3://your-bucket-name/your-location。如果文件已经在 s3 中,您可以使用aws s3 cp命令将其复制到新位置。

  2. 使用 Hive 在您的文件位置之上创建表。

use your_schema; create external table test( col1 string, col2 string, ... coln type ) row format delimited fields terminated by ',' lines terminated by '\n' location 's3://your-bucket-name/your-location/'; 检查它在 Hive 中是否有效:

select * from your_schema.test limit 10;
  1. 使用 Presto 查询您的表

select * from your_schema.test limit 10;

于 2018-08-27T17:19:57.623 回答