[
https://issues.apache.org/jira/browse/SPARK-15916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15327106#comment-15327106
]
Hyukjin Kwon commented on SPARK-15916:
--------------------------------------
Indeed. Do you mind if I submit a PR for this?
> JDBC AND/OR operator push down does not respect lower OR operator precedence
> ----------------------------------------------------------------------------
>
> Key: SPARK-15916
> URL: https://issues.apache.org/jira/browse/SPARK-15916
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 2.0.0
> Reporter: Piotr Czarnas
>
> A table from sql server Northwind database was registered as a JDBC dataframe.
> A query was executed on Spark SQL, the "northwind_dbo_Categories" table is a
> temporary table which is a JDBC dataframe to "[northwind].[dbo].[Categories]"
> sql server table:
> SQL executed on Spark sql context:
> SELECT CategoryID FROM northwind_dbo_Categories
> WHERE (CategoryID = 1 OR CategoryID = 2) AND CategoryName = 'Beverages'
> Spark has done a proper predicate pushdown to JDBC, however parenthesis
> around two OR conditions was removed. Instead the following query was sent
> over JDBC to SQL Server:
> SELECT "CategoryID" FROM [northwind].[dbo].[Categories] WHERE (CategoryID =
> 1) OR (CategoryID = 2) AND CategoryName = 'Beverages'
> As a result, the last two conditions (around the AND operator) were
> considered as the highest precedence: (CategoryID = 2) AND CategoryName =
> 'Beverages'
> Finally SQL Server has executed a query like this:
> SELECT "CategoryID" FROM [northwind].[dbo].[Categories] WHERE CategoryID = 1
> OR (CategoryID = 2 AND CategoryName = 'Beverages')
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]