分区依据给我创建外部 table 时重复的错误列

Partitioned by gives me error column duplicated when creating external table

我正在使用 'partitioned by' 创建外部 table,但出现以下错误:

 'Invalid operation: column "#id" duplicated'

我一开始以为可能和#这个字符有关,但后来我换了一个专栏,我也犯了同样的错误。 (以防万一有人问起#,我将文件从 csv 上传到 S3,其中 header 包括 # 并且在将 table 创建为没有此 # 的名称时我无法更改列名,否则它只会带来空值。)

CREATE EXTERNAL TABLE schema.table_name
(
   #id            BIGINT,
   uf             varchar(255)
)



 partitioned by (#id BIGINT,
                  uf varchar(255))
  row format delimited
  fields terminated by ','
  stored as parquet
  location 's3://bucket/folder/'

您的问题是您正在尝试使用列已在使用的名称来命名分区。

正如您在文档中看到的 here,这是不允许的:

Create an external table and specify the partition key in the PARTITIONED BY clause. The partition key can't be the name of a table column. [...]

只需重命名您的分区即可。