是否可以将字段添加到现有 AWS Athena table 中的结构?

Is it possible to add fields to struct in an existing AWS Athena table?

我有一个 table 跟踪用户在定义为(不相关字段等已删除)的高吞吐量网站上的操作:

CREATE EXTERNAL TABLE `actions`(
  `uuid` string COMMENT 'from deserializer', 
  `action` string COMMENT 'from deserializer', 
  `user` struct<id:int,username:string,country:string,created_at:string> COMMENT 'from deserializer')
PARTITIONED BY ( 
  `ingestdatetime` string)
ROW FORMAT SERDE 
  'org.openx.data.jsonserde.JsonSerDe' 
STORED AS INPUTFORMAT 
  'org.apache.hadoop.mapred.TextInputFormat' 
OUTPUTFORMAT 
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  's3://<path_to_bucket>'
TBLPROPERTIES (
  'transient_lastDdlTime'='1506104792')

并希望向用户数据添加更多字段(例如 level:int 以跟踪用户执行操作时的级别)。

是否可以更改 table 定义以包含这些新属性,如果可以,是否可以配置默认值以防它们不在源数据文件中?

不,您不能在 Athena 中向结构添加新列。 您可以删除架构,然后创建一个包含所需列的新 Table。 删除架构或数据库不会影响您的数据,因为 Athena 本身不存储数据,它只是指向 S3 中的数据。