AWS - Redshift - Unload 数据到S3产生的文件名
当 Redshift Unload 数据时,文件名称会根据表的分配方式及数据分布有关。
实验一: 表分配方式为 ALL,数据存在在多个节点,无法预计从哪个节点导出数据。默认情况下,表数据量小时,按ALL分配,变大之后改为EVEN
-- Create Table
testdb=# create table test_unload_19_all (id int);
CREATE TABLE
-- Insert row
testdb=# insert into test_unload_19_all values (0);
INSERT 0 1
-- Table Diststyle
testdb=# select "table", diststyle from pg_catalog.svv_table_info where "table" = 'test_unload_19_all';table | diststyle
--------------------+-----------test_unload_19_all | AUTO(ALL)
(1 row)
-- Table rows in slices
testdb=# select trim(name) as table, stv_blocklist.slice, stv_tbl_perm.rows
from stv_blocklist,stv_tbl_perm
where stv_blocklist.tbl=stv_tbl_perm.id
and stv_tbl_perm.slice=stv_blocklist.slice
and stv_blocklist.id > 10000 and name not like '%#m%'
and name not like 'systable%'
and name = 'test_unload_19_all' -- tablename
group by name, stv_blocklist.slice, stv_tbl_perm.rows
order by 2 desc;table | slice | rows
--------------------+-------+------test_unload_19_all | 6 | 1test_unload_19_all | 4 | 1test_unload_19_all | 2 | 1test_unload_19_all | 0 | 1
(4 rows)
-- Unload to S3
testdb=# unload ('select * from test_unload_19_all')
testdb-# to 's3://XXXXX/XXXXX/test_unload_19_all'
testdb-# iam_role 'arn:aws-cn:iam::000000000000:role/XXXXX'
testdb-# format as parquet
testdb-# allowoverwrite;
INFO: UNLOAD completed, 1 record(s) unloaded successfully.
UNLOAD
– Unload file name
test_unload_19_all0002_part_00.parquet
-- Unload to S3 again
testdb=# unload ('select * from test_unload_19_all')
testdb-# to 's3://XXXXX/XXXXX/test_unload_19_all'
testdb-# iam_role 'arn:aws-cn:iam::000000000000:role/XXXXX'
testdb-# format as parquet
testdb-# allowoverwrite;
INFO: UNLOAD completed, 1 record(s) unloaded successfully.
UNLOAD
– Unload file name
test_unload_19_all0004_part_00.parquet
由于数据存在在 切片 0,2,4,6 中,所以无法预计本次导出时从哪个文件中导出。
实验二:表分配方式为 KEY , EVEN,数据仅保存在一个分片中,则每次导出结果为一致。
testdb=# create table test_unload_19_even (id int) diststyle even;
CREATE TABLE
testdb=# insert into test_unload_19_even values (0);
INSERT 0 1
testdb=# select "table", diststyle from pg_catalog.svv_table_info where "table" = 'test_unload_19_even';table | diststyle
---------------------+-----------test_unload_19_even | EVEN
(1 row)
testdb=# select trim(name) as table, stv_blocklist.slice, stv_tbl_perm.rows
from stv_blocklist,stv_tbl_perm
where stv_blocklist.tbl=stv_tbl_perm.id
and stv_tbl_perm.slice=stv_blocklist.slice
and stv_blocklist.id > 10000 and name not like '%#m%'
and name not like 'systable%'
and name = 'test_unload_19_even' -- tablename
group by name, stv_blocklist.slice, stv_tbl_perm.rows
order by 2 desc;table | slice | rows
---------------------+-------+------test_unload_19_even | 4 | 1
(1 row)
-- Unload to S3
testdb=# unload ('select * from test_unload_19_even')
testdb-# to 's3://XXXXX/XXXXX/test_unload_19_even'
testdb-# iam_role 'arn:aws-cn:iam::000000000000:role/XXXXX'
testdb-# format as parquet
testdb-# allowoverwrite;
INFO: UNLOAD completed, 1 record(s) unloaded successfully.
UNLOAD
-- Unload file name
test_unload_19_even0004_part_00.parquet
-- Unload to S3
testdb=# unload ('select * from test_unload_19_even')
testdb-# to 's3://XXXXX/XXXXX/test_unload_19_even'
testdb-# iam_role 'arn:aws-cn:iam::000000000000:role/XXXXX'
testdb-# format as parquet
testdb-# allowoverwrite;
INFO: UNLOAD completed, 1 record(s) unloaded successfully.
UNLOAD
-- Unload file name
test_unload_19_even0004_part_00.parquet
-- 分配方式为Key
testdb=# create table test_unload_19_key (id int) diststyle key distkey (id);
CREATE TABLE
testdb=# insert into test_unload_19_key values (0);
INSERT 0 1
testdb=# select "table", diststyle from pg_catalog.svv_table_info where "table" = 'test_unload_19_key';table | diststyle
--------------------+-----------test_unload_19_key | KEY(id)
(1 row)
testdb=# select trim(name) as table, stv_blocklist.slice, stv_tbl_perm.rows
testdb-# from stv_blocklist,stv_tbl_perm
testdb-# where stv_blocklist.tbl=stv_tbl_perm.id
testdb-# and stv_tbl_perm.slice=stv_blocklist.slice
testdb-# and stv_blocklist.id > 10000 and name not like '%#m%'
testdb-# and name not like 'systable%'
testdb-# and name = 'test_unload_19_key' -- tablename
testdb-# group by name, stv_blocklist.slice, stv_tbl_perm.rows
testdb-# order by 2 desc;table | slice | rows
--------------------+-------+------test_unload_19_key | 7 | 1
(1 row)
testdb=# unload ('select * from test_unload_19_key')
testdb-# to 's3://chen-redshift-spectrum/redshift-unload/test_unload_19_key'
testdb-# iam_role 'arn:aws-cn:iam::524560386974:role/chen-redshift-role'
testdb-# format as parquet
testdb-# allowoverwrite;
INFO: UNLOAD completed, 1 record(s) unloaded successfully.
UNLOAD
– file name
test_unload_19_key0007_part_00.parquet
当表的分配方式为 Key 与 Even 时,多次导出文件名称不变。只会跟切片有关。
AWS - Redshift - Unload 数据到S3产生的文件名相关推荐
- aws rds恢复数据库_使用AWS Glue将数据从AWS S3加载到AWS RDS SQL Server数据库
aws rds恢复数据库 This article explains how to develop ETL (Extract Transform Load) jobs using AWS Glue t ...
- 如何将数据仓库从 AWS Redshift 迁移到阿里云 AnalyticDB for PostgreSQL
阿里云AnalyticDB for PostgreSQL(以下简称 ADB PG,即原HybridDB for PostgreSQL)为基于PostgreSQL内核的MPP架构的实时数据仓库服务,可以 ...
- AWS - redshift 中的锁
AWS Redshift 是云中数据仓库服务.通过大规模并行处理.列式数据存储和非常高效且具有针对性的数据压缩编码方案的组合,实现高效存储和最优查询性能. AWS Redshift中有三种锁定模式:[ ...
- 【AWS 安全系列】Amazon S3 配置错误(下)
[AWS 安全系列]Amazon S3 配置错误(下) [AWS 安全系列]Amazon S3 配置错误(下) 1. 怎样发现存储桶? a. 使用 aws cli 工具 b. 查看网站的HTTP 响应 ...
- AWS Lambda将数据保存在DynamoDB中
在本教程中,我们将看到如何使用AWS Lambda将数据保存在Dynamo DB中. 这是必需的步骤: – 在Dynamo数据库中创建一个名为Employee的表 –创建一个AWS Lambda函数, ...
- aws redshift_从本地安装的IDE访问AWS Redshift
aws redshift This article gives you an overview of configuring the AWS Redshift cluster to use it fr ...
- 使用 Learner Lab - 使用 AWS Lambda 将图片写入 S3
使用 Learner Lab - 使用 AWS Lambda 将图片写入 S3 AWS Academy Learner Lab 是提供一个帐号让学生可以自行使用 AWS 的服务,让学生可以在 100 ...
- [转载] AWS之EMR数据ES通过数据仓库HIVE同步S3
参考链接: AWS创建S3存储桶 本篇主要讲解利用EMR将ES中PB级数据利用HIVE数据仓库同步到S3,从而利用Athena对数据进行分析计算: EMR搭建 1 软件配置(如图) 注意:hive和 ...
- 使用Apache Hudi + Amazon S3 + Amazon EMR + AWS DMS构建数据湖
1. 引入 数据湖使组织能够在更短的时间内利用多个源的数据,而不同角色用户可以以不同的方式协作和分析数据,从而实现更好.更快的决策.Amazon Simple Storage Service(amaz ...
最新文章
- linux shell函数
- jQuery length 和 size()区别
- Flash AS3.0实例教程:构建简单的声音可视化程序(波型图)
- 解决:Google代码achartengine曲线代码报错问题(转)
- 使用lucene3.6创建索引和实现简单搜索
- LeetCode-13.罗马数字转整数
- 语音识别代码_Povey正式出任小米语音首席科学家,小米移动端框架MACE全面支持Kaldi...
- python opencv 识别角度_opencv python 角点检测/FAST算法
- 匿名飞控代码解读汇总
- 论文查重算法 python_个人项目之论文查重
- Spring Boot学习笔记
- 技术岗面试中的一些常见问题
- 上海海洋大学计算机专硕调剂,2019年上海海洋大学硕士研究生调剂政策和规则...
- Calendar 用法
- 汇报工作的六大原则,不然怎么努力也白费
- 用css规范php的输出,一段很小但很实用的CSS打印类(附例子及_php
- Win10系统桌面图标突然变成白色如何恢复
- 核心单词Word List 45
- 情绪识别软件?论程序员对猫的偏爱!
- 修改3389远程端口号