---
title: Type mismatch troubleshooting
meta:
  description: Common issues and solutions for type mismatches in ClickHouse and Tinybird.
---

# Type mismatch troubleshooting

Common issues and solutions for type mismatches in ClickHouse and Tinybird.

## Common errors

### TYPE_MISMATCH

**Error**: `TYPE_MISMATCH: Cannot convert String to UInt32`

**Cause**: Trying to use incompatible data types in operations

**Solution**: Cast to appropriate type
```sql
-- Wrong
SELECT numeric_column + string_column FROM events

-- Correct
SELECT numeric_column + toUInt32(string_column) FROM events
```

### NO_COMMON_TYPE

**Error**: `NO_COMMON_TYPE: There is no supertype for types String and UInt32`

**Cause**: No common type for operation

**Solution**: Explicitly cast to common type
```sql
-- Cast both to string for concatenation
SELECT toString(numeric_column) || string_column FROM events
```

## Type conversion issues

### String to numeric conversion

**Issue**: Converting strings to numbers with invalid data

**Solution**: Use safe conversion functions
```sql
-- Use safe conversion
SELECT toUInt32OrNull(string_column) as safe_number
FROM events
```

### Date type mismatches

**Issue**: Mixing different date types

**Solution**: Use consistent date types
```sql
-- Convert to consistent date type
SELECT toDate(date_column) as consistent_date
FROM events
```

## Schema design issues

### Inconsistent column types

**Issue**: Same logical data with different types across tables

**Solution**: Standardize column types
```sql
-- Use consistent types across tables
-- Instead of: table1.id (String), table2.id (UInt32)
-- Use: table1.id (UInt32), table2.id (UInt32)
```

### Type inference problems

**Issue**: ClickHouse inferring wrong types from data

**Solution**: Explicitly specify column types
```sql
-- Explicitly specify types in schema
CREATE TABLE events (
  id UInt32,
  value Float64,
  timestamp DateTime
) ENGINE = MergeTree()
```

## Best practices

1. **Use explicit types** - Don't rely on type inference
2. **Use safe conversions** - Use `toTypeOrNull()` functions
3. **Standardize types** - Use consistent types across tables
4. **Validate data** - Check data before type conversions
5. **Document types** - Keep track of expected data types

## Related documentation

- [Data types](/sql-reference/data-types)
- [Type conversion functions](/sql-reference/functions/type-conversion-functions)
- [Common error patterns](/forward/dev-reference/common-error-patterns)
