U127: Column cannot be cast to type

Category: Application / User Errors
SQLSTATE: 42804 (Class 42 — Syntax Error or Access Rule Violation: datatype_mismatch)
Urgency: low

Example Postgres Log Output:

ERROR: column "abc" cannot be cast to type "date"
STATEMENT: SELECT abc::date FROM x

Explanation:

Your query is trying to cast the referenced column to a data type that is not supported for the original data type.

Usually this would occur when you assume the original data type is something different from what it actually is.

Recommended Action:

Fix the query to either use a different target type, or adjust the source column to have the correct type.

In some cases you may also need multiple type casts to get your desired result.

Learn More:


Download Free eBook: The Top 6 Postgres Log Events
Couldn't find what you were looking for or want to talk about something specific?
Start a conversation with us →