使用Redshift Spectrum查询Hive视图

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

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视图?我正在使用Hive Metastore(不是胶水数据目录)。

我想要一个视图,以限制对原始表的访问,该表具有有限的列和分区集。另外,由于我的原始表(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,但是这很混乱,因为属性是Map字段,而不是Struct,所以我需要在Redshift中将其爆炸成几行。

谢谢

kingkong1900 回答:使用Redshift Spectrum查询Hive视图

看着错误,似乎在查询外部表和视图时Spectrum总是在寻找S3路径。 这对外部表有效,因为外部表将始终具有位置,而视图将永远不会具有显式的S3位置。

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

对于蜂巢视图, loc->length()将返回0,整个语句将返回False并导致断言错误。

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

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

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

loc->length() > 5

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

本文链接:https://www.f2er.com/2549684.html

大家都在问