Skip to content

Commit 80a6fb5

Browse files
committed
[SPARK-10080] [SQL] Fix binary incompatibility for $ column interpolation
Turns out that inner classes of inner objects are referenced directly, and thus moving it will break binary compatibility. Author: Michael Armbrust <[email protected]> Closes #8281 from marmbrus/binaryCompat. (cherry picked from commit 80cb25b) Signed-off-by: Michael Armbrust <[email protected]>
1 parent 2bccd91 commit 80a6fb5

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ class SQLContext(@transient val sparkContext: SparkContext)
334334
@Experimental
335335
object implicits extends SQLImplicits with Serializable {
336336
protected override def _sqlContext: SQLContext = self
337+
338+
/**
339+
* Converts $"col name" into an [[Column]].
340+
* @since 1.3.0
341+
*/
342+
// This must live here to preserve binary compatibility with Spark < 1.5.
343+
implicit class StringToColumn(val sc: StringContext) {
344+
def $(args: Any*): ColumnName = {
345+
new ColumnName(sc.s(args: _*))
346+
}
347+
}
337348
}
338349
// scalastyle:on
339350

sql/core/src/main/scala/org/apache/spark/sql/SQLImplicits.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ import org.apache.spark.unsafe.types.UTF8String
3333
private[sql] abstract class SQLImplicits {
3434
protected def _sqlContext: SQLContext
3535

36-
/**
37-
* Converts $"col name" into an [[Column]].
38-
* @since 1.3.0
39-
*/
40-
implicit class StringToColumn(val sc: StringContext) {
41-
def $(args: Any*): ColumnName = {
42-
new ColumnName(sc.s(args: _*))
43-
}
44-
}
45-
4636
/**
4737
* An implicit conversion that turns a Scala `Symbol` into a [[Column]].
4838
* @since 1.3.0

sql/core/src/test/scala/org/apache/spark/sql/test/SharedSQLContext.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package org.apache.spark.sql.test
1919

20-
import org.apache.spark.sql.SQLContext
20+
import org.apache.spark.sql.{ColumnName, SQLContext}
2121

2222

2323
/**
@@ -65,4 +65,14 @@ private[sql] trait SharedSQLContext extends SQLTestUtils {
6565
}
6666
}
6767

68+
/**
69+
* Converts $"col name" into an [[Column]].
70+
* @since 1.3.0
71+
*/
72+
// This must be duplicated here to preserve binary compatibility with Spark < 1.5.
73+
implicit class StringToColumn(val sc: StringContext) {
74+
def $(args: Any*): ColumnName = {
75+
new ColumnName(sc.s(args: _*))
76+
}
77+
}
6878
}

0 commit comments

Comments
 (0)