select字段列表中无法使用计算出来的值进行再次计算
结论:在select列表中无法直接使用计算得到的字段,进行再次计算。
单独执行如下语句,可以执行成功
> select CURRENT_TIMESTAMP as ts;
+--------------------------+
| ts |
+--------------------------+
| 2021-09-03 05:30:10.983 |
+--------------------------+
单独执行如下语句,可以执行成功
> select unix_timestamp('2021-09-03 05:30:10.983');
+-------------+
| _c0 |
+-------------+
| 1630647010 |
+-------------+
但是执行如下语句则会报错,提示ts示无效的
> select CURRENT_TIMESTAMP as ts,unix_timestamp(ts);
Error: Error while compiling statement: FAILED: SemanticException [Error 10004]: Line 1:46 Invalid table alias or column reference 'ts': (possible column names are: ) (state=42000,code=10004)
通过子查询进行,ts可以正常使用。
select unix_timestamp(a.ts) from(select CURRENT_TIMESTAMP as ts) a;
+-------------+
| _c0 |
+-------------+
| 1630647296 |
+-------------+