[
https://issues.apache.org/jira/browse/SPARK-12218?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15048256#comment-15048256
]
Xiao Li commented on SPARK-12218:
---------------------------------
That is what I did in my environment.
{code}
val df1 = Seq(1, 2, 3).map(i => (i, i, i.toString)).toDF("int1", "int2",
"str")
df1.where("not (int1=0 and int2=0)").explain(true)
df1.where("not(int1=0) or not(int2=0)").explain(true)
{code}
Their physical plans are exactly the same.
{code}
== Parsed Logical Plan ==
'Filter NOT (('int1 = 0) && ('int2 = 0))
+- Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Analyzed Logical Plan ==
int1: int, int2: int, str: string
Filter NOT ((int1#3 = 0) && (int2#4 = 0))
+- Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Optimized Logical Plan ==
Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- Filter (NOT (_1#0 = 0) || NOT (_2#1 = 0))
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Physical Plan ==
Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- Filter (NOT (_1#0 = 0) || NOT (_2#1 = 0))
+- LocalTableScan [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
{code}
{code}
== Parsed Logical Plan ==
'Filter (NOT ('int1 = 0) || NOT ('int2 = 0))
+- Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Analyzed Logical Plan ==
int1: int, int2: int, str: string
Filter (NOT (int1#3 = 0) || NOT (int2#4 = 0))
+- Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Optimized Logical Plan ==
Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- Filter (NOT (_1#0 = 0) || NOT (_2#1 = 0))
+- LocalRelation [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
== Physical Plan ==
Project [_1#0 AS int1#3,_2#1 AS int2#4,_3#2 AS str#5]
+- Filter (NOT (_1#0 = 0) || NOT (_2#1 = 0))
+- LocalTableScan [_1#0,_2#1,_3#2], [[1,1,1],[2,2,2],[3,3,3]]
{code}
> Boolean logic in sql does not work "not (A and B)" is not the same as "(not
> A) or (not B)"
> --------------------------------------------------------------------------------------------
>
> Key: SPARK-12218
> URL: https://issues.apache.org/jira/browse/SPARK-12218
> Project: Spark
> Issue Type: Bug
> Components: SQL
> Affects Versions: 1.5.2
> Reporter: Irakli Machabeli
> Priority: Blocker
>
> Two identical queries produce different results
> In [2]: sqlContext.read.parquet('prp_enh1').where(" LoanID=62231 and not(
> PaymentsReceived=0 and ExplicitRoll in ('PreviouslyPaidOff',
> 'PreviouslyChargedOff'))").count()
> Out[2]: 18
> In [3]: sqlContext.read.parquet('prp_enh1').where(" LoanID=62231 and (
> not(PaymentsReceived=0) or not (ExplicitRoll in ('PreviouslyPaidOff',
> 'PreviouslyChargedOff')))").count()
> Out[3]: 28
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]