How to add a new Struct column to a DataFrame

前端 未结 2 1635
南方客
南方客 2020-12-08 05:19

I\'m currently trying to extract a database from MongoDB and use Spark to ingest into ElasticSearch with geo_points.

The Mongo database has latitude and

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 05:54

    Try this:

    import org.apache.spark.sql.functions._
    
    df.registerTempTable("dt")
    
    dfres = sql("select struct(lat,lon) as colName from dt")
    

提交回复
热议问题