Now I want to calculate the hash or sparse vector of all the values in column1 and column2
You can use VectorAssembler. It creates SparseVector by default.
VectorAssembler
SparseVector
You can use
VectorAssembler. It createsSparseVectorby default.