It’s probably not advisable to use 1 though since it will break when `df = df2`,
which can easily happen when you’ve written a function that does such a join internally.
This could be solved by an identity like function that returns the dataframe unchanged but with a different identity.
`.as` would be such a candidate but that doesn’t work.
There are several ways to solve this ambiguity:
1. use the DataFrames to get the attribute so its already "resolved" and not just a string we need to map to a DataFrame.
df.join(df2, df("_1") === df2("_1"))
2. Use aliases
3. rename the columns as you suggested.
df.join(df2.withColumnRenamed("_1", "right_key"), $"_1" === $"right_key").printSchema
4. (Spark 1.4 only) use def join(right: DataFrame, usingColumn: String): DataFrame
This has the added benefit of only outputting a single _1 column.