Select Redshift Spectrum 中带有连字符的字段

Select field with Hyphen in Redshift Spectrum

我正在尝试通过 Redshift Spectrum 提取名称中带有连字符的嵌套字段

SELECT mystruct.mysubstruct.my-field.id
FROM my_external_schema.my_table 

我在其他DBMS中看到建议将字段名用双引号引起来:

"mystruct.mysubstruct.my-field.id"

或反勾号

`mystruct.mysubstruct.my-field.id`

但其中 none 对我有用。

有什么建议吗?

由于双引号允许对特殊字符进行转义,因此执行 "mystruct.mysubstruct.my-field.id" 意味着您在顶层查找名为 'mystruct.mysubstruct.my-field.id' 的列而不是嵌套列,因为点是不用于提取字段。

你要做的是

SELECT mystruct.mysubstruct."my-field".id
FROM my_external_schema.my_table