【发布时间】:2020-04-24 10:54:39
【问题描述】:
我正在尝试按 id 获取每个组中第一行的记录。行号由id的顺序生成。我一直收到同样的错误[10004]。
这个hive脚本是在SAS studio环境下构建的,下面是一段proc sql代码:
数据集 id_f 包含变量 x,y 和 z
execute (create temporary table event_id_f1 as
select *,ROW_NUMBER() OVER(ORDER BY id) as rownum
from id_f
group by id
having rownum = min(rownum)
)
by df20;
错误:执行错误:org.apache.hive.service.cli.HiveSQLException:编译语句时出错:FAILED:SemanticException [错误 10004]:第 1:129 行无效的表别名或列引用“rownum”:(可能的列名称为:x、y、z)
感谢任何帮助!
@bernie 建议 Hive 不识别别名。我应该如何嵌套别名以使其工作?代码也在执行语句中。 我的尝试:
execute (create temporary table event_id_f1 as
from (
select *,
ROW_NUMBER() OVER(ORDER BY id) as rownum
from id_f
group by id
having rownum = min(rownum) ) ranked
WHERE ranked=1
)
by df20;
【问题讨论】:
-
@bernie 你知道如何将我当前的代码转换为嵌套选择的行号而不是别名吗?我试图转换它,不确定它是否正确。我第一次在 Hive 中编码。您可以刷新帖子以查看我的尝试。
-
@bernie 刚刚做了一些修改..
-
我只是发布了我写它的方式。告诉我系统是否返回任何其他错误。
-
@bernie 我明天就会知道,而不是通过工作计算机。非常感谢!