Átomo
38Sw
Spark em Scala · Scala

select / withColumn

Abrir na tabela

Definição

Escolhem e criam colunas.

Exemplos

1. select
val slim = df.select("customer_id", "sale_date", "amount")
2. withColumn
val enriched = df
  .withColumn("year", year($"sale_date"))
  .withColumn("load_ts", current_timestamp())
3. Renomear e remover
df.withColumnRenamed("cust_id", "customer_id").drop("temp_col")

No mesmo grupo