Spark Dataset select with typedcolumn

后端 未结 2 1888
不知归路
不知归路 2021-02-02 17:39

Looking at the select() function on the spark DataSet there are various generated function signatures:

(c1: TypedColumn[MyClass, U1],c2: TypedColumn         


        
2条回答
  •  盖世英雄少女心
    2021-02-02 18:12

    In the Scala DSL for select, there are many ways to identify a Column:

    • From a symbol: 'name
    • From a string: $"name" or col(name)
    • From an expression: expr("nvl(name, 'unknown') as renamed")

    To get a TypedColumn from Column you simply use myCol.as[T].

    For example: ds.select(col("name").as[String])

提交回复
热议问题