VectorUDT usage

后端 未结 1 1745
余生分开走
余生分开走 2020-12-12 02:52

I have to get the datatype and do a case match and convert it to some required format. But the usage of org.apache.spark.ml.linalg.VectorUDT is showing Ve

1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 03:33

    For org.apache.spark.ml.linalg types you should specify schema using org.apache.spark.ml.linalg.SQLDataTypes which provide singleton instances of the private UDT types:

    • MatrixType for matrices (org.apache.spark.ml.linalg.Matrix).

      scala> org.apache.spark.ml.linalg.SQLDataTypes.MatrixType.getClass
      res0: Class[_ <: org.apache.spark.sql.types.DataType] = class org.apache.spark.ml.linalg.MatrixUDT
      
    • VectorType for vectors (org.apache.spark.ml.linalg.Vector).

      scala> org.apache.spark.ml.linalg.SQLDataTypes.VectorType.getClass
      res1: Class[_ <: org.apache.spark.sql.types.DataType] = class org.apache.spark.ml.linalg.VectorUDT
      

    0 讨论(0)
提交回复
热议问题