scala - Why is join not possible after show operator? -
the following code works fine until add show
after agg
. why show
not possible?
val temptableb = tableb.groupby("idb") .agg(first("numb").as("numb")) //when add .show here, doesn't work tablea.join(temptableb, $"ida" === $"idb", "inner") .drop("ida", "numa").show
the error says:
error: overloaded method value join alternatives: (right: org.apache.spark.sql.dataset[_],joinexprs: org.apache.spark.sql.column,jointype: string)org.apache.spark.sql.dataframe <and> (right: org.apache.spark.sql.dataset[_],usingcolumns: seq[string],jointype: string)org.apache.spark.sql.dataframe cannot applied (unit, org.apache.spark.sql.column, string) tablea.join(temptableb, $"ida" === $"idb", "inner") ^
why behaving way?
.show()
function with, call in scala, side-effect. prints stdout , returns unit()
, println
example:
val = array(1,2,3).foreach(println) a: unit = ()
in scala, can assume function , return something. in case, unit()
being returned , that's what's getting stored in temptableb
.
Comments
Post a Comment