Complete the code to perform a cross join between two DataFrames df1 and df2.
result = df1.[1](df2)The crossJoin method performs a cross join between two DataFrames in Apache Spark.
Complete the code to count the number of rows in the cross join result.
count = df1.crossJoin(df2).[1]()The count() method returns the number of rows in a DataFrame.
Complete the code to enable cross joins explicitly (required before using crossJoin).
spark.conf.set('spark.sql.crossJoin.enabled', [1])
To allow cross joins in Spark, set the configuration spark.sql.crossJoin.enabled to the string 'true'.
Complete the code to calculate the expected number of rows in a cross join result (product of individual row counts).
expected_rows = df1.[1]() * df2.[1]()
A cross join (cartesian product) results in df1.count() * df2.count() rows, which grows very large for big DataFrames—avoid unless necessary.
Complete the code to disable cross joins to prevent accidental performance issues with large datasets.
spark.conf.set('spark.sql.crossJoin.enabled', [1])
'true' or true which enables cross joins.false instead of string 'false'.Setting spark.sql.crossJoin.enabled to 'false' (default) disables cross joins, avoiding massive cartesian products and OOM errors.