amazon-redshift-spectrum - 红移光谱显示所有行的 NULL 值
问题描述
当我在 Athena 查询编辑器中运行此查询时,它按预期工作。
SELECT * FROM "sampledb"."elb_logs" 限制 10;
elb_logs 表已根据官方教程生成。当我尝试在红移中使用光谱时,我可以看到所有列的所有“NULL”值。我正在使用这些命令创建 athena_schema:
drop schema "athena_schema";
create external schema athena_schema from data catalog
database 'sampledb'
iam_role 'arn:aws:iam::94331XXXXXXX:role/RedshiftCopyUnload'
region 'ap-south-1';
系统表的输出:
从 svv_external_tables 中选择 *;
schemaname tablename location input_format output_format serialization_lib serde_parameters compressed parameters
athena_schema elb_logs s3://athena-examples-ap-south-1/elb/plaintext org.apache.hadoop.mapred.TextInputFormat org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat org.apache.hadoop.hive.serde2.RegexSerDe {"input.regex":"([^ ]*) ([^ ]*) ([^ ]*):([0-9]*) ([^ ]*):([0-9]*) ([.0-9]*) ([.0-9]*) ([.0-9]*) (-|[0-9]*) (-|[0-9]*) ([-0-9]*) 0 {"EXTERNAL":"TRUE","transient_lastDdlTime":"1480278335"}
我不确定为什么 athena 控制台显示所有列的正确值,而 redshift 显示所有 NULL?
解决方案
这是因为 elb_logs 表使用了频谱无法处理的正则表达式序列化。我使用此命令将表格转换为镶木地板文件格式。
CREATE TABLE elb_logs3
WITH (
format = 'PARQUET',
parquet_compression = 'SNAPPY',
external_location = 's3://elb163/parqfiles'
) AS SELECT * from elb_logs
现在 athena 将有 2 个表“elb_logs”和“elb_logs3”。一旦我使用像这样的标准命令创建外部模式......
drop schema "athena_schema";
create external schema athena_schema from data catalog
database 'sampledb'
iam_role 'arn:aws:iam::XXX:role/RedshiftCopyUnload'
region 'us-east-1';
我现在可以像这样从 elb_logs 表中选择记录...
select * from athena_schema.elb_logs3 限制 10;
请注意,从 elb_logs 表中选择仍然显示所有列的 NULL 值。
推荐阅读
- android - 尽管在视口元中设置了 user-scalable=no,但允许在 web 视图中进行缩放
- node.js - 三重 DES Node.js 密钥/IV 长度问题
- sql - 根据最大分类出现过滤表
- postgresql - PostgreSQL按另一列值的范围自动增加列
- django - 通过 jsonb 字段执行 Django 加入和分组
- php - 如何在restful api中验证来自post的数据
- c++ - 使用包含互斥锁的类的方法实例化 cpp11 线程
- android - Android 错误:使用对话框时无法从可绘制资源中找到 ColorStateList
- python - 多处理 - 取消池中剩余的作业而不破坏池
- java - 如何自定义 Java GraphQL 错误响应