'Extraneous input '\' expecting {')', ','}. Query working in sql notebook cell but not in databricks connect

When executing the following query

SELECT * FROM companies JOIN employments on companies.company_normalized LIKE CONCAT('%',
    replace(employments.displayname_normalized, '\\', ''), '%') or employments.displayname_normalized LIKE CONCAT(
    '%', replace(companies.company_normalized,'\\', ''), '%')

it works fine on databricks sql notebook cell.

However, when attempting to run this same query using spark sql executor, ie spark.sql(query), this errors out saying: Extraneous input '' expecting {')', ','} within the replace clause.

Is there a fix for this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source