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

# SQL compilation error in the warehouse

> Resolve the error returned when your data warehouse rejects the SQL before running it.

## Error message

```text wrap theme={null}
Failed to execute query in warehouse <name>: SQL compilation error: <details>
```

This error can appear when using the following components: [Database Query](https://docs.maia.ai/docs/components/database-query.md), [SQL Script](https://docs.maia.ai/docs/components/sql-script.md), and [transformation components](https://docs.maia.ai/docs/components/transformation-pipeline-overview.md).

### Explanation

The data warehouse rejected the SQL before running it. The warehouse's own explanation follows the words `SQL compilation error` and usually includes a line and position.

### Potential causes

* A table, view, or column doesn't exist, or its name is spelled or cased differently from the SQL.
* The role running the query lacks privileges on an object it uses.
* A syntax error, or a variable that was replaced with an unexpected value.

***

## Resolve the error

1. Read the text after `SQL compilation error:`. It names the object or position the warehouse couldn't accept.
2. Open the SQL that Maia generated for the component and run it in your warehouse's query editor, using the same role.
3. Confirm the database, schema, table, and column names exist and match in spelling and case.
4. Confirm the role has the privileges the query needs.
5. Fix the pipeline and re-run.
6. If you still need help, [contact Maia Support](https://support.matillion.com/s/) and include the items listed below.

   * The full warehouse error text.
   * The role and warehouse used by the environment.

### Prevent future errors

To prevent this error occurring again, [validate pipelines](https://docs.maia.ai/docs/guides/validating-pipelines.md) before running them against production schemas.


## Related topics

- [Grid variable does not contain the expected column](https://docs.maia.ai/docs/errors/grid-variable-does-not-contain-the-expected-column.md)
- [For input string: value cannot be converted to a number](https://docs.maia.ai/docs/errors/for-input-string-value-cannot-be-converted-to-a-number.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.