现在想要诸如此类样式的语句:(过去三个月的)
可以用python脚本写:
from datetime import date, timedelta
# 获取当前日期
current_date = date.today()
# 定义过去三个月的时间间隔
three_months_ago = current_date - timedelta(days=90)
# 遍历生成分区数据
while current_date >= three_months_ago:
partition_name = current_date.strftime("pt_%Y%m%d")
partition_value = current_date.strftime("%Y-%m-%d")
partition_statement = f"PARTITION `{partition_name}` VALUES IN ('{partition_value}'),"
print(partition_statement)
current_date -= timedelta(days=1)