Issue
When executing a Reverse ETL model query in the Segment workspace, the query fails to run and returns the message: googleapi: Error 400: Syntax error: Expected ")" but got ";". Customers typically encounter this syntax error in the Query Builder when attempting to preview data or run a sync.
Product
Segment
Environment
Segment Console
Cause
Segment Reverse ETL executes your custom SQL queries by wrapping them in a Common Table Expression (CTE), which can only bind the results from one single subquery. If you include one or multiple semicolons (;) in your query, the system treats them as multiple separate subqueries. Even if the semicolon is simply placed inside an inline comment, it breaks the CTE execution and triggers the syntax error.
Resolution
To resolve this error, you need to ensure your query is treated as a single subquery:
- Navigate to Connections > Sources, select the Reverse ETL tab, and choose your source.
- Select the affected model and open it in the SQL Editor.
- Review your SQL statement and remove all semicolons (;) from the query, paying close attention to any semicolons hidden within inline comments.
- Click Preview to verify that the query now runs successfully without the syntax error.
- Save your changes to the model.
Additional Information
If you are copying and pasting complex queries from external tools into the Segment Query Builder, it is recommended to use a SQL minifier to ensure all unnecessary formatting, tabs, and hidden characters are removed before pasting.