Athena : HIVE_BAD_DATA

0

I got this error after loading a parquet file from S3 into Athena. HIVE_BAD_DATA: Field metadata_file's type BINARY in parquet file s3://dil-google-books/data/dataset.parquet/part-00108-33efb610-5e72-4e37-b646-3b4ab4578bad-c000.snappy.parquet is incompatible with type boolean defined in table schema

Could you please suggest what I need to do?

CREATE EXTERNAL TABLE IF NOT EXISTS all_dataset (
  AccessDate string,
  Authors string,
  Chapter string,
  Chron string,
  City string,
  Degree string,
  Edition string,
  Encyclopedia string,
  Format string,
  ID_list string,
  Issue string,
  Pages string,
  Periodical string,
  PublicationPlace string,
  PublisherName string,
  Series string,
  SeriesNumber string,
  Title string,
  TitleType string,
  URL string,
  Volume string,
  citations string,
  id int,
  page_title string,
  r_id int,
  r_parentid int,
  sections string,
  type_of_citation string,
  updated_identifier array <string> ,
  conf_score array <double>)
STORED AS PARQUET
LOCATION 's3:/'
tblproperties ("parquet.compress"="SNAPPY");
已提问 2 年前3162 查看次数
2 回答
1

There are several versions of the HIVE_BAD_DATA error. One reason might be because The data type defined in the table definition doesn't match the actual source data and another reason might be a single field contains different types of data (for example, a boolean value for one record and a decimal value for another record).

In your case, you need to change the type in the schema to the appropriate data type (in your case it's binary).

I would suggest you format your data in AWS Glue (ETL Programming) then you can load into Athena Via Glue Data Catalog or directly from query.

Ref Links:

https://aws.amazon.com/premiumsupport/knowledge-center/athena-hive-bad-data-parsing-field-value/

https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format.html

已回答 2 年前
AWS
专家
已审核 2 年前
0

As per my understanding you have some files where the column is typed as binary and some where it is typed as boolean. When you type the column of the table as boolean Athena will eventually read a file where the corresponding column is boolean and throw this error, and vice versa.The solution is to make sure your files all have the same schema.

profile picture
已回答 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则