Problem
You install PolyBase and the Databricks Simba ODBC driver in your Azure environment to allow Azure Synapse Analytics, and then create a query with this setup in your Databricks environment. When you try to execute the query, you encounter a PARSE_SYNTAX_ERROR
message.
Cause
PolyBase handles the conversion of queries from MS SQL server syntax to Apache Spark SQL syntax. Issues during the conversion process can lead to parsing errors.
Example
In the following example, you provide SQL query 1. The conversion process results in SQL query 2, which is invalid in Spark SQL syntax.
The issue is located in the last two lines. The segment ON (`t0`.`fieldB` = `T_3`.`fieldB`)) `t4`
is misplaced and should have been included after the first join.
SQL query 1
SELECT COUNT_big(table0.fieldA)
FROM schema.table0 t0
INNER JOIN schema.table1 t1 ON t0.fieldB = t1.fieldB
INNER JOIN schema.table2 da ON t0.fieldC = t2.fieldC
WHERE t2.fieldD >= 20241101
SQL query 2
SELECT `fieldA` `fieldA`
FROM (SELECT (COUNT(0)) `fieldA`
FROM `catalog`.`schema`.`table0` `t0`
INNER JOIN `catalog`.`schema`.`table1` `t1`
INNER JOIN (SELECT `t2`.`fieldB`, `t2`.`fieldC`
FROM `schema`.`catalog`.`table` `t2`
WHERE (`t2`.`fieldD` >= (20241001))) `t3`
ON (`t3`.`fieldA` = `T_1`.`fieldA`)
ON (`t0`.`fieldB` = `T_3`.`fieldB`)) `t4`
Solution
The error stems from the Microsoft side and requires their support team to assist.
- Contact the Microsoft technical support team for help retrieving the ODBC driver logs from your Azure environment.
- Locate the PARSE_SYNTAX_ERROR in the logs. The converted query appears next to the error message.
- Report the issue to Microsoft technical support to fix the problem. Send your original query together with the error message that contains the invalid generated query.