VALUES Statement | 6.3.x | Cloudera Documentation

SELECT now()  as date_DES
UNION ALL
SELECT trunc(now(), 'month')
union all
select date_sub(trunc(now(), 'month'), 1)
union all
select add_months( date_sub(trunc(now(), 'month'), 1),-12)
union all
select ''
union all
select add_months( date_sub(trunc(now(), 'month'), 1), 0) date_des
1 2023-01-11 09:04:53.304718000 now()
2 2023-01-01 00:00:00 trunc(now(), 'month') -- 获得月份首日
3 2022-12-31 00:00:00 date_sub(trunc(now(), 'month'), 1) --日期减1天
4 2021-12-31 00:00:00 add_months( date_sub(trunc(now(), 'month'), 1),-12) --R12,上个月的最后一天,减去12个月
5 NULL
6 2022-12-31 00:00:00 add_months( date_sub(trunc(now(), 'month'), 1), 0) --上个月的最后一天 从impala 3.0 开始,在group by、having和order by子句中的别名替换逻辑变得更加符合标准的行为,如下所示。
别名现在只在顶层合法,而不是在subexpressions中。 SELECT int_col / 2 AS x FROM t GROUP BY x;
SELECT int_col / 2 AS x FROM t ORDER BY x;
SELECT NOT bool_col AS nb FROM t GROUP BY nb HAVING nb;
和以下语句是不允许的。 SELECT int_col / 2 AS x FROM t GROUP BY x / 2;
SELECT int_col / 2 AS x FROM t ORDER BY -x;
SELECT int_col / 2 AS x FROM t GROUP BY x HAVING x > 3
-----------------------------------
https://blog.51cto.com/u_15278282/2932154 > SELECT * FROM (VALUES(4,5,6),(7,8,9)) AS t;
+---+---+---+
| 4 | 5 | 6 |
+---+---+---+
| 4 | 5 | 6 |
| 7 | 8 | 9 |
+---+---+---+ > SELECT * FROM (VALUES(1 AS c1, true AS c2, 'abc' AS c3),(100,false,'xyz')) AS t;
+-----+-------+-----+
| c1 | c2 | c3 |
+-----+-------+-----+
| 1 | true | abc |
| 100 | false | xyz |
+-----+-------+-----+
> VALUES (CAST('2019-01-01' AS TIMESTAMP)), ('2019-02-02');
+---------------------------------+
| cast('2019-01-01' as timestamp) |
+---------------------------------+
| 2019-01-01 00:00:00 |
| 2019-02-02 00:00:00 |
+------------------ From <https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/impala_values.html#values>
select 'FOOBAR' ilike 'f%';
+---------------------+
| 'foobar' ilike 'f%' |
+---------------------+
| true |
+---------------------+ select 'FOOBAR' like 'f%';
+--------------------+
| 'foobar' like 'f%' |
+--------------------+
| false |
+--------------------+ select 'ABCXYZ' not ilike 'ab_xyz';
+-----------------------------+
| not 'abcxyz' ilike 'ab_xyz' |
+-----------------------------+
| false From <https://docs.cloudera.com/documentation/enterprise/6/6.3/topics/impala_operators.html#ilike>
Solution 1
impala-shell> set var:id=123;select * from users where id=${VAR:id}; This variable can also be passed from command-line using --var impala-shell --var id=123
impala-shell> select * from users where id=${VAR:id};
Solution 2
There's an open feature request for adding variable substitution support to impala-shell: IMPALA-1067, to mimic Hive's similar feature
(hive --hivevar param=60 substitutes ${hivevar:param} inside a query with 60). Variables that you can use in other SQL contexts (e.g. from a JDBC client) are not supported either,

and I couldn't even find an open request for it... You might want to open a request for it: https://issues.cloudera.org/browse/IMPALA

最新文章

  1. C++ 异常机制
  2. 解决iOS9下隐藏App返回按钮文字导致的诡异闪屏问题
  3. 也学习Java/JVM/GC(四)
  4. PAT/简单模拟习题集(一)
  5. angularJs , json,html片段,bootstrap timepicker angular
  6. CodeForces 166B (凸包)
  7. SELECT的解析顺序及慢查询优化
  8. LightOj1054 - Efficient Pseudo Code ( 求n的m次方的因子和 )
  9. webtest 文章
  10. hdu2571动态规划
  11. 字典与集合(Dictionary与Collection)
  12. Laravel 简单使用七牛云服务
  13. jquery各版本区别
  14. Java线程:锁
  15. ES6关于Unicode的相关扩展
  16. Spring Cloud 2-Ribbon 客户端负载均衡(二)
  17. (转)Spring4.0:@Configuration
  18. 浅析SQLite的锁机制和WAL技术
  19. Java学习08 (第一遍) - SpringMVC
  20. Linux系统管理员非常使用的几款工具推荐

热门文章

  1. Integer使用==比较的问题
  2. LeetCode-396 选转函数
  3. Abp返回时间格式化
  4. @FileLimit – AOP最佳实践:上传文件大小限制
  5. lg7863
  6. ssh操作
  7. Cannot read properties of null (reading ‘insertBefore‘)
  8. Java中如何处理大批量照片上传,然后调用图片上传服务区接口,使用异步吗,是不是需要用到多线程
  9. 记录将Base64字符串转化为图片遇到的问题
  10. java ArrayList 原理