Amazon Athena HIVE_BAD_DATA: Error Parsing a column in the table: Cannot convert value of type String to a REAL value

0

On AWS Athena, query csv data then get error as below even though just select * from table

HIVE_BAD_DATA: Error Parsing a column in the table: Cannot convert value of type String to a REAL value

by the way select count(*) from table was success. how to solve this error?

kyamada
asked a month ago58 views
2 Answers
2

This error can occur in the following scenarios:

The data type defined in the table doesn't match the source data, or a single field contains different types of data. For suggested resolutions, see My Amazon Athena query fails with the error "HIVE_BAD_DATA: Error parsing field value for field x: For input string: "12312845691"" in the AWS Knowledge Center.

Null values are present in an integer field. One workaround is to create the column with the null values as string and then use CAST to convert the field in a query, supplying a default value of 0 for nulls. For more information, see When I query CSV data in Athena, I get the error "HIVE_BAD_DATA: Error parsing field value '' for field x: For input string: """ in the AWS Knowledge Center.

profile pictureAWS
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
0

Hi Kyamada,

You can download the csv file, then check the column that you are querying to check if in the column it has a NULL or not-like NUMBER format (ex: a123).

The problem happen because of some values in column you are using is STRING but expected to NUMBER.

profile picture
answered a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions