当前位置:网站首页>Scala104-Spark.sql的内置日期时间函数
Scala104-Spark.sql的内置日期时间函数
2022-08-04 18:29:00 【51CTO】
有些时候我们会直接用df.createOrReplaceTempView(temp)创建临时表,用sql去计算。sparkSQL有些语法和hql不一样,做个笔记。
- <scala.version>2.11.12</scala.version>
- <spark.version>2.4.3</spark.version>
timestamp转string
把timestamp转换成对应格式字符串
- date_format把timestamp转换成对应的字符串
- 字符串格式用"yyyyMMdd"表示
timestamp转date
- to_date可以把timestamp转换成date类型
求时间差
- 天数差函数datediff可以应用在timestamp中,也可应用在date类型中,单位是自然天,而不是24小时
- 月份差函数months_between同样可以,月度的单位好像是不固定的,即31天or30天
Ref
2020-03-24 于南京市江宁区九龙湖
边栏推荐
- limux入门3—磁盘与分区管理
- 合宙Cat1 4G模块Air724UG配置RNDIS网卡或PPP拨号,通过RNDIS网卡使开发板上网(以RV1126/1109开发板为例)
- Introduction of three temperature measurement methods for PT100 platinum thermal resistance
- PHP代码审计10—命令执行漏洞
- 老电脑怎么重装系统win10
- Flink / Scala - 使用 RedisSink 存储数据
- C#爬虫之通过Selenium获取浏览器请求响应结果
- 使用scikit-learn计算文本TF-IDF值
- Global electronics demand slows: Samsung's Vietnam plant significantly reduces capacity
- 数仓建模面试
猜你喜欢

Nintendo won't launch any new hardware until March 2023, report says

Iptables防火墙基础知识介绍

Matlab drawing 1

2018年南海区小学生程序设计竞赛详细答案

使用scikit-learn计算文本TF-IDF值

悦刻难回巅峰
![[Web Automation Test] Quick Start with Playwright, 5 minutes to get started](/img/68/36dd8ef4a4073f03d5e5dad91be20d.png)
[Web Automation Test] Quick Start with Playwright, 5 minutes to get started

开篇-开启全新的.NET现代应用开发体验

Develop those things: How to obtain the traffic statistics of the monitoring site through the EasyCVR platform?

DHCP&OSPF combined experimental demonstration (Huawei routing and switching equipment configuration)
随机推荐
#yyds干货盘点# 面试必刷TOP101:链表相加(二)
Hezhou Cat1 4G module Air724UG is configured with RNDIS network card or PPP dial-up, and the development board is connected to the Internet through the RNDIS network card (taking the RV1126/1109 devel
The prefix and discretization
clickhouse online and offline table
Flink/Scala - Storing data with RedisSink
基于 eBPF 的 Kubernetes 可观测实践
巴比特 | 元宇宙每日必读:微博动漫将招募全球各类虚拟偶像并为其提供扶持...
JS兼容问题总结
npm配置国内镜像(淘宝镜像)
如何给MySQL添加自定义语法 ?
BigDecimal 使用注意!!“别踩坑”
(ECCV-2022)GaitEdge:超越普通的端到端步态识别,提高实用性
关于使用腾讯云HiFlow场景连接器每天提醒签到打卡
mood swings
Google Earth Engine APP - one-click online viewing of global images from 1984 to this year and loading an image analysis at the same time
谁能解答?从mysql的binlog读取数据到kafka,但是数据类型有Insert,updata,
使用scikit-learn计算文本TF-IDF值
用Excel绘制统计图
Babbitt | Metaverse daily must-read: Weibo animation will recruit all kinds of virtual idols around the world and provide support for them...
数仓建模面试