Error 50: UNKNOWN_TYPE
This error occurs when ClickHouse encounters an unrecognized data type name, typically due to typos in type names, missing required type parameters, using types not available in your ClickHouse version, or incorrect syntax in complex type definitions.
Most common causes
-
Misspelled or incorrect type names
- Typos in common type names (Int32 vs Int23, String vs Str)
- Case sensitivity issues (string vs String)
- Wrong type family (using PostgreSQL or MySQL type names)
- Deprecated type names in newer versions
-
Missing required type parameters
- FixedString without length specification
- Decimal without precision and scale
- DateTime64 without precision parameter
- Enum without value definitions
- LowCardinality wrapping undefined types
-
Complex nested type syntax errors
- Invalid Array, Tuple, or Map type definitions
- Incorrect nesting of parameterized types
- Missing parentheses or brackets in complex types
- Wrong separator usage (comma vs space)
-
Version-specific type availability
- Using types introduced in newer ClickHouse versions e.g.
TimeorTime64data types - Types removed or renamed in version upgrades. e.g deprecated
Objectdata type - Experimental types not available in your build
- Using types introduced in newer ClickHouse versions e.g.
-
Type inference failures
- Ambiguous
NULLtypes inINSERTstatements - Empty arrays without explicit type specification
- Complex expressions where type cannot be determined
- Type conflicts in
UNIONqueries
- Ambiguous
Common solutions
1. Fix typos in type names
2. Add required type parameters
3. Specify Decimal precision and scale
4. Fix complex nested type syntax
5. Correct Tuple and Map type definitions
6. Specify DateTime64 precision
7. Enable experimental types
8. Fix Enum definitions
9. Specify types for Nullable and LowCardinality
10. Use correct nested type syntax
11. Explicit type casting in queries
Prevention tips
- Reference official documentation for type names: Always check the ClickHouse documentation for exact type names and syntax, as type names are case-sensitive and must match exactly (e.g.,
Stringnotstring) - Use type parameters consistently: For parameterized types (FixedString, Decimal, DateTime64, Enum), always include required parameters and verify syntax in documentation before creating tables
- Test complex types incrementally: When building complex nested types (Array of Tuples, Maps with complex values), test simpler versions first and add complexity gradually
- Validate type compatibility with ClickHouse version: Before using newer data types, verify they're available in your ClickHouse version by checking release notes or testing in development first
- Use explicit type casting: When dealing with
NULLs, empty arrays, or ambiguous expressions, use explicitCAST()or::syntax to specify exact types - Enable required experimental settings in session: If using experimental types (Object, JSON, Variant), enable necessary settings at the session level and document these requirements for production
- Maintain type consistency across schema: When creating related tables or views, ensure type definitions match exactly to avoid type inference issues in JOINs and UNION operations
- Use schema inference carefully: When using table functions (s3, url, file), explicitly specify types instead of relying on inference to avoid UNKNOWN_TYPE errors from ambiguous data
Related error codes
- ILLEGAL_TYPE_OF_ARGUMENT (43) - Wrong type used for function argument
- CANNOT_CONVERT_TYPE (70) - Type conversion not possible
- TYPE_MISMATCH (386) - Types don't match in operation
- UNKNOWN_IDENTIFIER (47) - Column or identifier not found