> ## Documentation Index
> Fetch the complete documentation index at: https://docs.narrative.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Type Validation Error

> The statistics configuration is incompatible with the dataset schema or Rosetta Stone attribute types

## Error message

```
{path}: {detail}; {path}: {detail}; ...
```

Examples:

* `price: mean is not compatible with type string`
* `address: primitive config does not match schema type object`
* `events.payload: property 'user_agent' not found in schema`

## When this error occurs

After the configuration passes structural validation (no duplicate stats, no mixed node types, etc.), the server validates it against the **actual schema** of the dataset or Rosetta Stone attributes. This error is raised when the configured statistics are incompatible with the field types in the schema.

There are four categories of type validation errors:

### 1. Stat incompatible with field type

A statistic is requested on a column whose type does not support it.

**Type compatibility rules:**

| Stat                                              | Compatible types                                           |
| ------------------------------------------------- | ---------------------------------------------------------- |
| `value_count`, `null_value_count`, `completeness` | All types                                                  |
| `approx_count_distinct`, `count_distinct`         | All types                                                  |
| `histogram`                                       | All types                                                  |
| `mean`, `standard_deviation`                      | Numeric only (`long`, `double`)                            |
| `nan_value_count`                                 | Numeric only (`long`, `double`)                            |
| `lower_bound`, `upper_bound`                      | Ordered types (`long`, `double`, `timestamp_tz`, `string`) |

**Example:** requesting `mean` on a string column.

```json theme={null}
{
  "defaults": {
    "enabled_stats": ["value_count"]
  },
  "refresh": { "trigger": "manual" },
  "dataset": {
    "fields": [
      {
        "field_name": "country",
        "enabled_stats": ["value_count", "mean"]
      }
    ]
  }
}
```

If `country` is a `string` column in the dataset schema, the server returns:

```
country: mean is not compatible with type string
```

**Fix:** Remove `mean` and use stats compatible with strings:

```json theme={null}
{
  "field_name": "country",
  "enabled_stats": ["value_count", "approx_count_distinct"]
}
```

### 2. Shape mismatch between config and schema

The configuration structure does not match the field's schema type. For example, using primitive config fields (`enabled_stats`) on an object column, or using non-primitive config fields (`properties`) on a string column.

**Example:** treating an object column as a primitive.

```json theme={null}
{
  "defaults": {
    "enabled_stats": ["value_count"]
  },
  "refresh": { "trigger": "manual" },
  "dataset": {
    "fields": [
      {
        "field_name": "address",
        "enabled_stats": ["value_count", "histogram"]
      }
    ]
  }
}
```

If `address` is an `object` column (with children `city`, `zip`, `state`), the server returns:

```
address: primitive config does not match schema type object
```

**Fix:** Use non-primitive config for object columns:

```json theme={null}
{
  "field_name": "address",
  "self": {
    "enabled_stats": ["null_value_count"]
  },
  "properties": [
    {
      "path": "city",
      "enabled_stats": ["value_count", "histogram"]
    }
  ]
}
```

The reverse also applies — using object config on a primitive column:

```json theme={null}
{
  "field_name": "user_id",
  "properties": [
    {
      "path": "name",
      "enabled_stats": ["value_count"]
    }
  ]
}
```

If `user_id` is a `string`, the server returns:

```
user_id: object config does not match schema type string
```

### 3. Unknown property in schema

A property listed in the `properties` array does not exist in the object's schema.

**Example:** configuring a non-existent child property.

```json theme={null}
{
  "defaults": {
    "enabled_stats": ["value_count"]
  },
  "refresh": { "trigger": "manual" },
  "dataset": {
    "fields": [
      {
        "field_name": "address",
        "properties": [
          {
            "path": "city",
            "enabled_stats": ["value_count"]
          },
          {
            "path": "country",
            "enabled_stats": ["value_count"]
          }
        ]
      }
    ]
  }
}
```

If `address` has children `city`, `zip`, and `state` but no `country`, the server returns:

```
address.country: property 'country' not found in schema
```

**Fix:** Remove the property or correct the path to match the schema:

```json theme={null}
{
  "field_name": "address",
  "properties": [
    {
      "path": "city",
      "enabled_stats": ["value_count"]
    },
    {
      "path": "state",
      "enabled_stats": ["value_count"]
    }
  ]
}
```

### 4. Nested type incompatibility

For deeply nested structures (arrays of objects, objects containing arrays), the validation recurses into children. Errors report the full path.

**Example:** requesting `mean` on a string property inside an array of objects.

Consider a dataset with column `events` of type `array<object<name: string, score: double>>`.

```json theme={null}
{
  "defaults": {
    "enabled_stats": ["value_count"]
  },
  "refresh": { "trigger": "manual" },
  "dataset": {
    "fields": [
      {
        "field_name": "events",
        "self": {
          "enabled_stats": ["null_value_count"]
        },
        "items": {
          "properties": [
            {
              "path": "name",
              "enabled_stats": ["value_count", "mean"]
            },
            {
              "path": "score",
              "enabled_stats": ["value_count", "mean"]
            }
          ]
        }
      }
    ]
  }
}
```

The `score` field (double) supports `mean`, but `name` (string) does not. The server returns:

```
events.[].name: mean is not compatible with type string
```

**Fix:** Remove `mean` from the string property:

```json theme={null}
{
  "path": "name",
  "enabled_stats": ["value_count", "approx_count_distinct"]
}
```

### 5. Field not found in dataset schema

A `field_name` in the `dataset.fields` array does not match any column in the dataset.

```json theme={null}
{
  "defaults": {
    "enabled_stats": ["value_count"]
  },
  "refresh": { "trigger": "manual" },
  "dataset": {
    "fields": [
      {
        "field_name": "nonexistent_column",
        "enabled_stats": ["value_count"]
      }
    ]
  }
}
```

```
nonexistent_column: field 'nonexistent_column' not found in dataset schema
```

**Fix:** Verify the column name matches the dataset schema exactly. Column names are case-sensitive.

## Multiple errors in one response

The validator reports all errors found, not just the first. Multiple errors are separated by semicolons:

```
price: mean is not compatible with type string; address: primitive config does not match schema type object; events.[].name: nan_value_count is not compatible with type string
```

## Quick reference: common mistakes

| Mistake                                   | Error                                                 | Fix                                                  |
| ----------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------- |
| `mean` on a string column                 | `mean is not compatible with type string`             | Use `approx_count_distinct` or `histogram` instead   |
| `nan_value_count` on a non-numeric column | `nan_value_count is not compatible with type boolean` | Remove — NaN only applies to floats                  |
| `lower_bound` on a boolean column         | `lower_bound is not compatible with type boolean`     | Remove — booleans have no meaningful ordering        |
| Flat stats on an object column            | `primitive config does not match schema type object`  | Use `self` + `properties` instead of `enabled_stats` |
| Object config on a scalar column          | `object config does not match schema type string`     | Use `enabled_stats` directly                         |
| Non-existent property in `properties`     | `property 'x' not found in schema`                    | Check the schema for correct property names          |
| Non-existent field in `fields`            | `field 'x' not found in dataset schema`               | Check the dataset schema for correct column names    |

## Related errors

* [Mixed Primitive and Non-Primitive Configuration](/reference/architecture/dataset-statistics/errors/mixed-node-config) — structural mismatch caught before type validation
* [Unsupported Statistics for Container Node](/reference/architecture/dataset-statistics/errors/unsupported-self-stats) — `self` stats limited to `null_value_count`
