Sparksql 日期加减函数

spark sql 日期加减,date_sub,date_add

val dateDF=spark.range(10) .withColumn("today",current_date()) .withColumn("now",current_timestamp()) dateDF.createOrReplaceTempView("dateTable") dateDF.printSchema() dateDF.select(date_sub(col("today"),5),date_add(col("today"),5)).show(1) spark.sql("select date_sub(today,5),date_add(today,5) from dateTable").show(1)

猜你喜欢

转载自www.cnblogs.com/ssqq5200936/p/11742290.html