No buildable side is ≤ 10 MB and preferSortMergeJoin=true → sort-merge join.
== Physical Plan ==AdaptiveSparkPlan isFinalPlan=false+- SortMergeJoin [customer_id#3L], [customer_id#10L], Inner :- Sort [customer_id#3L ASC NULLS FIRST], false, 0 : +- Exchange hashpartitioning(customer_id#3L, 200), ENSURE_REQUIREMENTS, [plan_id=40] : +- Filter isnotnull(customer_id#3L) : +- ColumnarToRow : +- FileScan parquet [order_id#0L,customer_id#3L,amount#5,order_date#6] Batched: true, Format: Parquet, Location: InMemoryFileIndex(1 paths)[s3://lake/orders], PushedFilters: [IsNotNull(customer_id)], ReadSchema: struct<order_id:bigint,customer_id:bigint,amount:decimal(10,2),order_date:date> +- Sort [customer_id#10L ASC NULLS FIRST], false, 0 +- Exchange hashpartitioning(customer_id#10L, 200), ENSURE_REQUIREMENTS, [plan_id=46] +- Filter isnotnull(customer_id#10L) +- ColumnarToRow +- FileScan parquet [customer_id#10L,country#12,segment#13,credit_limit#14] Batched: true, Format: Parquet, Location: InMemoryFileIndex(1 paths)[s3://lake/customers], PushedFilters: [IsNotNull(customer_id)], ReadSchema: struct<customer_id:bigint,country:string,segment:string,credit_limit:decimal(10,2)>from pyspark.sql import functions as F
spark.conf.set("spark.sql.adaptive.enabled", "true")
spark.conf.set("spark.sql.autoBroadcastJoinThreshold", "10MB") # default
orders = spark.read.parquet("s3://lake/orders/") # ~500 GB
customers = spark.read.parquet("s3://lake/customers/") # ~50 MB
joined = orders.join(customers, "customer_id", "inner")
joined.explain()