Я не думаю, что ранжирование без окон возможно, и в вашем случае, так как ранжирование должно происходить по всему набору данных, невозможно избежать оконной функции без partitionBy, но мы можем уменьшить огромное количество данных, поступающих в один раздел с кодом ниже.
sample = [(100,1000),(100, 1000), (100, 2000), (200, 1000), (200,1000), (300,1000), (300,2000)]
test = spark.createDataFrame(sample,['hdr','dtl'])
# Since we select only distinct of hdr and dtl huge amount of data is eliminated.
dist_hdr_dtl=test.select("hdr","dtl").distinct()
# Since data size is reduced we can use this window spec.
spec = Window.orderBy('hdr','dtl')
dist_hdr_dtl=dist_hdr_dtl.withColumn('final_rank', dense_rank().over(spec))
# join it with original data to get the ranks.
Note: if distinct dataset is not very huge you can use broadcast join which will improve performance
test.join(dist_hdr_dtl,["hdr","dtl"],"inner").orderBy('hdr','dtl').show()
+---+----+----------+
|hdr| dtl|final_rank|
+---+----+----------+
|100|1000| 1|
|100|1000| 1|
|100|2000| 2|
|200|1000| 3|
|200|1000| 3|
|300|1000| 4|
|300|2000| 5|
+---+----+----------+