-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] support ${yyyy-MM-dd%-2d} #2416
Labels
enhancement
New feature or request
Comments
duhanmin
changed the title
[Feature] 支持${yyyy-MM-dd%-2d}
[Feature] support ${yyyy-MM-dd%-2d}
Jul 5, 2022
Linkis内置时间变量介绍1.总述需求背景用户希望在写代码时,对时间的格式要求千变万化,已有的Linkis自定义变量目前还不足以支撑这些需求。另外,已有的时间运算-1有些表示减一个月,有些则是减一天,用户很容易混淆 目标
Pattern格式对照表:
2. 总体设计总体设计和技术架构参照Linkis自定义变量 3. 功能介绍Linkis支持的变量类型分为自定义变量(不做赘述)和系统内置变量,自定变量日期支持+-。 3.1 内置变量举例可以根据自己的喜好/业务实际情况定义需要动态渲染的参数
3.2 自定义变量使用实例
SELECT * FROM hive.tmp.fund_nav_histories
WHERE dt <= DATE_FORMAT(DATE_ADD('day', -1, DATE(Date_parse('${yyyyMMdd%-1d}', '%Y%m%d'))), '%Y%m%d') 渲染后 SELECT * FROM hive.tmp.fund_nav_histories
WHERE dt <= DATE_FORMAT(DATE_ADD('day', -1, DATE(Date_parse('20220705', '%Y%m%d'))), '%Y%m%d')
aws s3 ls s3://***/ads/tmp/dws_member_active_detail_d_20210601_20211231/pt=${yyyyMMdd%-1d}/ 渲染后 aws s3 ls s3://***/ads/tmp/dws_member_active_detail_d_20210601_20211231/pt=20220705/
{
"job": {
"setting": {
"speed": {
"channel": 1
}
},
"content": [
{
"reader": {
"name": "s3reader",
"parameter": {
"bucket": "**************",
"path": [
"ads/tmp/ccass_tm_announcements/${yyyyMMdd%-1d}/"
],
"stored": "parquet",
"compression": "NONE",
"column": [
{
"index": 0,
"type": "int"
},
{
"index": 1,
"type": "string",
"constant": "${yyyyMMdd%-1d}"
}
]
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"print": true
}
}
}
]
}
} 渲染后 {
"job": {
"setting": {
"speed": {
"channel": 1
}
},
"content": [
{
"reader": {
"name": "s3reader",
"parameter": {
"bucket": "**************",
"path": [
"ads/tmp/ccass_tm_announcements/20220705/"
],
"stored": "parquet",
"compression": "NONE",
"column": [
{
"index": 0,
"type": "int"
},
{
"index": 1,
"type": "string",
"constant": "20220705"
}
]
}
},
"writer": {
"name": "streamwriter",
"parameter": {
"print": true
}
}
}
]
}
}
print(${yyyyMMdd%-1d}) 渲染后
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Linkis built-in time variable introduction
1. General
Requirements Background
Users hope that when writing code, the time format requirements are ever-changing, and the existing Linkis custom variables is currently not enough to support these requirements. In addition, some of the existing time operation -1 means minus one month, and some minus one day, which is easy for users to confuse
Target
Pattern format comparison table:
2. Overall Design
The overall design and technical architecture refer to Linkis Custom Variables
3. Function introduction
The variable types supported by Linkis are divided into custom variables (not to be described in detail) and system built-in variables. The custom variable date supports +-.
3.1 Examples of built-in variables
You can define parameters that need to be dynamically rendered according to your own preferences/business actual situation
3.2 Custom Variable Usage Example
after rendering
after rendering
aws s3 ls s3://***/ads/tmp/dws_member_active_detail_d_20210601_20211231/pt=20220705/
after rendering
after rendering
The text was updated successfully, but these errors were encountered: