Skip to content

HIVE_INVALID_METADATA: Glue table 'bitx_static_config.test_table_1' column 'code' has invalid data type: varchar

0
  1. I am trying to create data catalog table in AWS glue which has different cols and their datatypes (varchar,date,timestamp). and the respective values are stored in CSV format in S3. But while querying the data on Athena,getting the Error:

HIVE_INVALID_METADATA: Glue table 'bitx_static_config.test_table_1' column 'code' has invalid data type: varchar

  1. while using string as a datatype for all the cols , query is successful.
  2. Can someone answer why it is not supporting varchar as a datatype?
asked a year ago290 views
1 Answer
0

The error you're encountering is due to a mismatch between the data types supported by AWS Glue and those supported by Athena. While AWS Glue supports the 'varchar' data type, Athena does not directly support it when querying tables.

Athena uses Presto as its query engine, which has a different set of supported data types. In Athena, the equivalent of 'varchar' is typically 'string'. This is why your query is successful when you use 'string' as the data type for all columns.

To resolve this issue, you have a few options:

  1. Use 'string' instead of 'varchar' when defining your columns in the AWS Glue Data Catalog. This is the simplest solution and will work well with Athena queries.

  2. If you need to maintain the 'varchar' data type in Glue for other purposes, you may need to create a separate table definition specifically for Athena use, where you map 'varchar' to 'string'.

  3. You could also consider using AWS Glue ETL jobs to transform your data and create a new table with compatible data types for Athena.

It's important to note that while 'varchar' and 'string' are functionally similar, 'string' in Athena doesn't have a length limit, whereas 'varchar' in some systems allows you to specify a maximum length. If you need to enforce length constraints, you may need to handle this in your application logic or through data validation processes.

When working with AWS Glue, Athena, and other AWS services, it's always a good practice to consult the documentation for the specific data types supported by each service to ensure compatibility across your data pipeline.
Sources
Data types - AWS Glue DataBrew

answered a year 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.