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

# Resolve SQL compilation errors

> Troubleshoot SQL compilation errors that appear in model previews, Customer Studio audiences and journeys, or sync runs.

SQL compilation errors in Hightouch usually come from your warehouse when Hightouch runs a query to preview a model, compute an audience, evaluate journey logic, or execute a sync.

In most cases, Hightouch is surfacing the warehouse's error message directly.

## Where these errors appear

You may see SQL compilation errors in:

* Model preview and model edits
* Customer Studio audience preview or count calculations
* Customer Studio journeys that evaluate audience/event conditions
* Sync run failures

## Quick checklist

When you hit a SQL compilation error:

1. Copy the full error message and note object names, column names, and line/position details.
2. Run the same SQL in your warehouse using the same role/context as Hightouch.
3. Classify the error pattern below.
4. Fix the issue at the right layer (warehouse object/permissions vs model/filter/mapping config).
5. Re-run model preview, then re-run the audience/journey/sync flow.

## Common error patterns

### Invalid identifier (including `_ht_to_filter`)

Example patterns:

* `SQL compilation error: invalid identifier ...`
* `invalid identifier '"_ht_to_filter"."COLUMN_NAME"'`

What it means:

* A referenced column is missing from the query result Hightouch is filtering or mapping.

Common causes:

* Column renamed or removed in model SQL.
* Audience filter, trait, journey condition, or sync mapping still references old column.

How to fix:

1. Confirm the column still exists in model output.
2. Update filters/conditions/mappings that reference the old name.
3. Preview and re-save the model if metadata is stale.

### Unresolved column with suggestions

Example pattern:

* `[UNRESOLVED_COLUMN.WITH_SUGGESTION] ... cannot be resolved. Did you mean ...`

What it means:

* A referenced column name does not exist in the active query output.

Common causes:

* Typo in a field name.
* Renamed/removed model column (for example after changing from `SELECT *` to an explicit column list).
* Stale audience, trait, journey filter, or suggestion-job configuration.

How to fix:

1. Verify the column exists in the parent model/event model output.
2. Preview and re-save the model to refresh available columns.
3. Update filter logic to use valid column names.

### Ambiguous column name

Example pattern:

* `SQL compilation error: ambiguous column name 'COLUMN_NAME'`

What it means:

* The final query references a column name that exists in multiple joined sources, and the warehouse cannot infer which one you intended.

Common causes:

* Multiple tables expose the same column name and the model output does not disambiguate with aliases.
* Downstream filters/mappings reference a shared name after query wrapping.

How to fix:

1. Alias ambiguous columns in model SQL (for example, `a.faq_url AS faq_url_from_a`, `b.faq_url AS faq_url_from_b`).
2. Update filters, traits, journeys, and sync mappings to reference the intended alias.
3. Re-run preview and dependent workflows.

### Object does not exist or not authorized

Example pattern:

* `Object 'DB.SCHEMA.OBJECT' does not exist or not authorized`

What it means:

* Warehouse object is missing, moved, renamed, or inaccessible to the configured role.

How to fix:

1. Verify object path (database/schema/object) is correct.
2. Confirm the Hightouch role has required `USAGE`/`SELECT` privileges.
3. Update model SQL or restore the object.

### View definition column mismatch

Example pattern:

* `View definition ... declared N column(s), but view query produces M column(s)`

What it means:

* The warehouse view definition is out of sync with the underlying query.

How to fix:

1. Recreate or repair the view in the warehouse.
2. Prefer explicit column lists over `SELECT *` in long-lived views.
3. Re-test the view in warehouse SQL before re-running in Hightouch.

### Invalid data type for predicate / row comparison

Example pattern:

* `Invalid data type ... for predicate [ROW(...)]`

What it means:

* Filter predicates compare incompatible data types.

How to fix:

1. Inspect predicate/filter logic for mixed types.
2. Align types with explicit `CAST(...)` where needed.
3. Re-test in warehouse, then in Hightouch.

### Works in warehouse UI but fails in Hightouch

What to check:

* Role differences between your user and Hightouch connection.
* Different default database/schema/warehouse context.
* Model points to a different object/version than expected.
* SQL succeeds in UI context but fails under Hightouch role with a standard pattern above.

How to fix:

1. Re-run under the same role/context as Hightouch.
2. Use fully qualified names (`DATABASE.SCHEMA.OBJECT`) in SQL.
3. Confirm Hightouch model references the intended object.

## When to contact support

Contact support with:

* Link to model/audience/journey/sync run
* Full SQL compilation error text
* Whether the error reproduces in warehouse SQL with the same role/context
