我没有任何特定的目的去了解这些奇怪名字的含义,我只是对此感兴趣。
这是一个简单的代码。
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
df1 = spark.createDataFrame([['a', 'b'], ['c', 'd']], 'c1: string, c2: string')
df2 = spark.createDataFrame([['a', 'p'], ['c', 'q']], 'c1: string, c3: string')
df1.join(df2, df1.c1 == df2.c1).explain()
输出
== Physical Plan ==
AdaptiveSparkPlan isFinalPlan=false
+- SortMergeJoin [c1#0], [c1#4], Inner
:- Sort [c1#0 ASC NULLS FIRST], false, 0
: +- Exchange hashpartitioning(c1#0, 200), ENSURE_REQUIREMENTS, [plan_id=191]
: +- Filter isnotnull(c1#0)
: +- Scan ExistingRDD[c1#0,c2#1]
+- Sort [c1#4 ASC NULLS FIRST], false, 0
+- Exchange hashpartitioning(c1#4, 200), ENSURE_REQUIREMENTS, [plan_id=192]
+- Filter isnotnull(c1#4)
+- Scan ExistingRDD[c1#4,c3#5]
列名称后面跟着数字,如
c1#0
和 c2#1
。这些数字是多少?我能理解的一件事是,它们有助于区分不同数据框中具有相同名称的列,例如 c1#0
和 c1#4
。
如有任何帮助,我们将不胜感激。