Craiu Constantin-Tiberiu created SPARK-62288:
------------------------------------------------
Summary: SQL Server LIKE pushdown does not escape [
Key: SPARK-62288
URL: https://issues.apache.org/jira/browse/SPARK-62288
Project: Spark
Issue Type: Bug
Components: SQL
Affects Versions: 4.0.0
Reporter: Craiu Constantin-Tiberiu
When {{{}startswith{}}}, {{endswith}} or {{contains}} is pushed down to SQL
Server, the value is sent inside a {{LIKE}} pattern without escaping {{{}[{}}}.
SQL Server treats {{[...]}} as a set of characters to match, not as literal
text, so the pushed filter returns different rows than Spark does without
pushdown.
https://learn.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql
- see docs:
{panel}
WHERE au_lname LIKE '[C-P]arsen' finds author last names ending with arsen and
starting with any single character between C and P, for example Carsen, Larsen,
Karsen, and so on. In range searches, the characters included in the range may
vary
{panel}
Example, with rows {{abc}} and {{{}x[b]y{}}}:
- {{{}contains(s, '[b]'){}}}: expected {{{}x[b]y{}}}, actual {{abc}} and
{{x[b]y}}
- {{startswith(s, '[')}} on a row {{{}[note]{}}}: expected {{{}[note]{}}},
actual no rows
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]