I have the query below which is EXCHANGING data to perform row_number() over a COLUMN on which the data is already exchanged in both the data sets
the table crime_parquet_table is a Bucketed table on the column Incident_Number with 30 buckets
explain
select
*
from
(
select *,
row_number() over(partition by Incident_Number order by Incident_Number) as rnk
from
(
select *
from
(
select /*+ REPARTITION(30,Incident_Number) */ *
from austin_crime_data_new
union all
select *
from crime_parquet_table
) tmp
)t
) d
where rnk = 1
below is the explain plan. I believe the +- Exchange (7) is not necessary. Let me know if you guys think otherwise and the reason for the same.
== Physical Plan ==
* Filter (10)
+- Window (9)
+- * Sort (8)
+- Exchange (7)
+- Union (6)
:- Exchange (3)
: +- * Project (2)
: +- Scan csv (1)
+- * ColumnarToRow (5)
+- Scan parquet default.crime_parquet_table (4)