hive - 使用 Redshift Spectrum 查询 Hive View

标签 hive amazon-redshift amazon-redshift-spectrum

我正在尝试使用 Redshift Spectrum 查询 Hive View ,但它给了我这个错误:

SQL Error [500310] [XX000]: [Amazon](500310) Invalid operation: Assert
Details: 
 -----------------------------------------------
  error:  Assert
  code:      1000
  context:   loc->length() > 5 && loc->substr(0, 5) == "s3://" - 
  query:     12103470
  location:  scan_range_manager.cpp:272
  process:   padbmaster [pid=1769]
  -----------------------------------------------;

是否可以从 Redshift Spectrum 查询 Hive View ?我正在使用 Hive Metastore(不是 Glue 数据目录)。

我想要一个 View 来限制对原始表的访问,其中包含一组有限的列和分区。而且因为我的原始表(Parquet 数据)有一些 Map 字段,所以我想做类似的事情,以便从 Redshift 查询更容易,因为 Map 字段在 Redshift 中处理起来有点复杂:

CREATE view my_view AS
SELECT event_time, event_properties['user-id'] as user_id, event_properties['product-id'] as product_id, year, month, day
FROM my_events
WHERE event_type = 'my-event'  -- partition

我可以从 Spectrum 查询表 my_events,但它很乱,因为 properties 是一个 Map 字段,而不是一个 Struct,所以我需要在 Redshift 中将它分解成几行。

谢谢

最佳答案

查看错误,Spectrum 似乎总是在查询外部表和 View 时寻找 S3 路径。 这对外部表有效,因为它们总是有一个位置,但 View 永远不会有一个明确的 S3 位置。

Error type    -> Assert
Error context -> context: loc->length() > 5 && loc->substr(0, 5) == "s3://"

如果是 hive View , loc->length() 将返回 0,整个语句将返回 False 并导致断言错误。

对此的确认可以是第二个子句:

loc->substr(0, 5) == "s3://"

它期望位置是 S3 路径,如果我们计算 "s3://" 中的字符数,它是 5,这也证实了第一个子句:

loc->length() > 5

看起来 Spectrum 不支持 Hive View (或者通常不支持任何没有显式 S3 路径的对象)

关于hive - 使用 Redshift Spectrum 查询 Hive View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60934904/

相关文章:

amazon-web-services - Redshift 数据 API 查询语句大小限制为 100 KB

mysql - 获取最近 x 天具有相同价格的产品

amazon-web-services - 如何连接到 Amazon Redshift 或 Apache Spark 中的其他数据库?

json - 从 AWS Glue 表到 RedShift Spectrum 外部表的日期字段转换

apache - 如何在 beeline 中指定 TGT kerberos 票证缓存

java - 集成测试 Hive 作业

sql - 如何使用 Hive 以分钟为单位获取日期差异

aws-cloudformation - 使用 Redshift Spectrum 进行云形成

amazon-web-services - 尝试访问 Amazon Redshift 外部表时出错

hadoop - 使用 hive 的合并语句将增量数据合并到外部表中