hive order by length() 报错

hql如下
select length(tag) from table1 order by length(tag) limit 20;
报错

FAILED: SemanticException [Error 10004]: Line...Invalid table alias or column reference 'tag': (possible column names are: _c0)

修改
用别名替代length(tag), 如下
select length(tag) as taglen from table1 order by taglen limit 20;

order by中可以使用普通函数(如to_date()),但是不能使用聚合函数(如count(), sum())。

你可能感兴趣的:(hive order by length() 报错)