我有像
这样的Hive查询SELECT Year, Month, Day, Hours, Minutes,
cast((cast(Seconds as int)/15) as int)*15
AS secondMod, Count(*) AS PerCount FROM LoggerTable
GROUP BY Year, Month, Day, Hours, Minutes, secondMod
ORDER BY PerCount;
上述查询失败并显示错误
失败:语义分析出错:第1行:175无效表别名或列引用secondMod
'LoggerTable'是一个包含所有字符串类型列的Hive表。
此问题的解决方法是什么?
答案 0 :(得分:12)
试试这个:
SELECT Year, Month, Day, Hours, Minutes,
cast((cast(Seconds as int)/15) as int)*15
AS secondMod, Count(*) AS PerCount FROM LoggerTable
GROUP BY Year, Month, Day, Hours, Minutes,
cast((cast(Seconds as int)/15) as int)*15
ORDER BY PerCount;
答案 1 :(得分:3)
在Hive 0.11.0及更高版本中,如果hive.groupby.orderby.position.alias
设置为true
,则可以按位置指定列。
请确认以下查询是否适合您。
SET hive.groupby.orderby.position.alias=true;
SELECT Year
,Month
,Day
,Hours
,Minutes
,cast((cast(Seconds as int)/15) as int)*15 AS secondMod
,count(*) AS PerCount
FROM LoggerTable
GROUP BY 1, 2, 3, 4, 5, 6
ORDER BY 7;