如何参数化Impala SQL日期在其中
我想在Impala 中对我的日期字符串进行参数化
查询:
WHERE
(From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') >= '2022-05-01 00:00:00.000'
AND From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') < '2022-05-31 23:59:59.000')
我的初始尝试:
SET VAR:INC_CREATE_START_DATE='2022-06-01 00:00:00.000';
SET VAR:INC_CREATE_END_DATE='2022-06-30 23:59:59.000';
.
.
WHERE (From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') >=$(VAR:INC_CREATE_START_DATE)
and From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') <$(VAR:INC_CREATE_END_DATE)
来自文档: https://impala.apache.org/docs/build3x/html/topics/impala_set.html
在Impala 2.5及更高版本中,SET还定义了Impala-Shell解释器的用户指定的替换变量。此功能使用Impala-Shell内置的SET命令,而不是SQL Set语句。因此,该替代机制仅与Impala-shell处理的查询一起工作,而不是通过JDBC或ODBC提交的查询。
还有其他选择或解决方法吗?这是非常基本的。
I would like to parametrize my date strings in an Impala Select
query:
WHERE
(From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') >= '2022-05-01 00:00:00.000'
AND From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') < '2022-05-31 23:59:59.000')
My initial attempt:
SET VAR:INC_CREATE_START_DATE='2022-06-01 00:00:00.000';
SET VAR:INC_CREATE_END_DATE='2022-06-30 23:59:59.000';
.
.
WHERE (From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') >=$(VAR:INC_CREATE_START_DATE)
and From_unixtime(Cast(MyDate AS BIGINT),'yyyy-MM-dd HH:mm:ss') <$(VAR:INC_CREATE_END_DATE)
From the docs: https://impala.apache.org/docs/build3x/html/topics/impala_set.html
In Impala 2.5 and higher, SET also defines user-specified substitution variables for the impala-shell interpreter. This feature uses the SET command built into impala-shell instead of the SQL SET statement. Therefore the substitution mechanism only works with queries processed by impala-shell, not with queries submitted through JDBC or ODBC.
Is there any other alternatives or workarounds? This is quite fundamental.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论