Difference between == and === in Scala, Spark

Generally speaking, they are just functions.

For different types, "==" and "===" might be defined or "overloaded" for different meanings.

For example, in some test framework, "===" is defined for some special function. See this.


The "==" is using the equals methods which checks if the two references point to the same object. The definition of "===" depends on the context/object. For Spark , "===" is using the equalTo method. See

  • for == https://spark.apache.org/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equals(java.lang.Object)
  • for === https://spark.apache.org/docs/2.0.0/api/java/org/apache/spark/sql/Column.html#equalTo(java.lang.Object)

(Since you are referencing Spark:) An important difference for Spark is the return value. For Column:

  • == returns a boolean

  • === returns a column (which contains the result of the comparisons of the elements of two columns)