alex-natzka commented on PR #3861:
URL: 
https://github.com/apache/arrow-datafusion/pull/3861#issuecomment-1283648809

   @Dandandan sorry, I could have been more specific in the PR description.
   
   The issue #3635 is mostly about one test that is currently ignored, namely 
[`multiple_or_predicates`](https://github.com/apache/arrow-datafusion/blob/5a700af57d2b7556fdca92ec3d7602c27d520183/datafusion/core/tests/sql/predicates.rs#L431).
   
   On current master (feff5dc80544) the produced logical plan is the following:
   ```
   [
       "Explain [plan_type:Utf8, plan:Utf8]",
       "  Projection: lineitem.l_partkey [l_partkey:Int64]",
       "    Projection: lineitem.l_partkey [l_partkey:Int64]",
       "      Filter: part.p_brand = Utf8(\"Brand#12\") AND lineitem.l_quantity 
>= Decimal128(Some(100),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(1100),15,2) AND part.p_size <= Int32(5) OR part.p_brand = 
Utf8(\"Brand#23\") AND lineitem.l_quantity >= Decimal128(Some(1000),15,2) AND 
lineitem.l_quantity <= Decimal128(Some(2000),15,2) AND part.p_size <= Int32(10) 
OR part.p_brand = Utf8(\"Brand#34\") AND lineitem.l_quantity >= 
Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(3000),15,2) AND part.p_size <= Int32(15) [l_partkey:Int64, 
l_quantity:Decimal128(15, 2), p_partkey:Int64, p_brand:Utf8, p_size:Int32]",
       "        Inner Join: lineitem.l_partkey = part.p_partkey 
[l_partkey:Int64, l_quantity:Decimal128(15, 2), p_partkey:Int64, p_brand:Utf8, 
p_size:Int32]",
       "          Filter: lineitem.l_quantity >= Decimal128(Some(100),15,2) AND 
lineitem.l_quantity <= Decimal128(Some(1100),15,2) OR lineitem.l_quantity >= 
Decimal128(Some(1000),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(2000),15,2) OR lineitem.l_quantity >= 
Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(3000),15,2) [l_partkey:Int64, l_quantity:Decimal128(15, 2)]",
       "            TableScan: lineitem projection=[l_partkey, l_quantity], 
partial_filters=[lineitem.l_quantity >= Decimal128(Some(100),15,2) AND 
lineitem.l_quantity <= Decimal128(Some(1100),15,2) OR lineitem.l_quantity >= 
Decimal128(Some(1000),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(2000),15,2) OR lineitem.l_quantity >= 
Decimal128(Some(2000),15,2) AND lineitem.l_quantity <= 
Decimal128(Some(3000),15,2)] [l_partkey:Int64, l_quantity:Decimal128(15, 2)]",
       "          Filter: part.p_size >= Int32(1) AND part.p_brand = 
Utf8(\"Brand#12\") AND part.p_size <= Int32(5) OR part.p_brand = 
Utf8(\"Brand#23\") AND part.p_size <= Int32(10) OR part.p_brand = 
Utf8(\"Brand#34\") AND part.p_size <= Int32(15) [p_partkey:Int64, p_brand:Utf8, 
p_size:Int32]",
       "            TableScan: part projection=[p_partkey, p_brand, p_size], 
partial_filters=[part.p_size >= Int32(1), part.p_brand = Utf8(\"Brand#12\") AND 
part.p_size <= Int32(5) OR part.p_brand = Utf8(\"Brand#23\") AND part.p_size <= 
Int32(10) OR part.p_brand = Utf8(\"Brand#34\") AND part.p_size <= Int32(15)] 
[p_partkey:Int64, p_brand:Utf8, p_size:Int32]",
   ]
   ```
   
   There is a double projection at the top of the plan; one of the projection 
nodes was introduced by `CommonSubexprEliminate`.
   
   The actual logical used to be even more nonsensical when #3635 was opened, 
c.f. our discussion 
[here](https://github.com/apache/arrow-datafusion/issues/3635#issuecomment-1276081962).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to