二百零九、Hive——with嵌套语句报错:hadoop.hive.ql.parse.SemanticException: Line 2:5 Ambiguous table alias ‘t2‘

这篇具有很好参考价值的文章主要介绍了二百零九、Hive——with嵌套语句报错:hadoop.hive.ql.parse.SemanticException: Line 2:5 Ambiguous table alias ‘t2‘。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

一、目的

在Hive的with嵌套语句时,HQL报错Line 2:5 Ambiguous table alias 't2'

二、报错详情

org.apache.hadoop.hive.ql.parse.SemanticException: Line 2:5 Ambiguous table alias 't2'文章来源地址https://www.toymoban.com/news/detail-807611.html

org.apache.hadoop.hive.ql.parse.semanticexception:column id found in more th,Hive,hadoop,hive,数据仓库

三、原SQL语句

with a2 as(
with t2 as(
select
       get_json_object(event_json,'$.id')             id,
       get_json_object(event_json,'$.deviceNo')       device_no,
       get_json_object(event_json,'$.createTime')     create_time,
       get_json_object(event_json,'$.objList')        obj_list
from hurys_dc_ods.ods_event)
select
        get_json_object(list_json,'$.id')             id,
        t2.device_no, create_time,
        get_json_object(list_json,'$.eventType') event_type,
        ''lane_no, ''speed,
        get_json_object(list_json,'$.posX')  pos_x,
        get_json_object(list_json,'$.posY')  pos_y,
        ''brand,''source_image, ''source_num, ''source_type, ''source_url, ''direction_radar,
        ''congestion_grade,''target_count, ''lane_no_original, ''event_type_detail,
        get_json_object(list_json,'$.targetLen')  target_len,
        ''queue_len,''queue_count,'' pos_head,''pos_tail,
        date(t2.create_time) day
from t2
lateral view explode(split(regexp_replace(regexp_replace(obj_list,
                                                '\\[|\\]','') ,  
                                 '\\}\\,\\{','\\}\\;\\{'), 
                   '\\;') 
          )list_obj as list_json
where t2.obj_list is not null
group by t2.device_no, get_json_object(list_json,'$.id'), create_time, get_json_object(list_json,'$.eventType'), get_json_object(list_json,'$.posX'), get_json_object(list_json,'$.posY'), get_json_object(list_json,'$.targetLen'))
select
a2.id, device_no, create_time, event_type, lane_no, speed, pos_x, pos_y, brand, source_image, source_num, source_type, source_url, direction_radar, congestion_grade, target_count, lane_no_original, event_type_detail, target_len, queue_len, queue_count, pos_head, pos_tail, day
from a2
;

四、报错原因

看报错提示,Ambiguous table alias 't2',似乎是with嵌套子语句命名t2报错,但是我试了很多其他命名,都报类似的错误,如果大家知道原因的话还望告知,谢谢!

五、解决方式

既然不能使用with嵌套子语句,那就换种方式。

(一)with语句等同与另一种SQL方式

1、原有SQL方式

> select w.word,count(1) num from 
> (select explode(split(line,"\\s")) word from wordcount) w 
> group by w.word order by num desc;

2、with语句

> with 
> t1 as (select explode(split(line,"\\s")) word from wordcount)
> select t1.word,count(1) num from t1 group by word order by num desc;

(二)新的SQL如下

with a2 as (
select
        get_json_object(list_json,'$.id')             id,
        t2.device_no, create_time,
        get_json_object(list_json,'$.eventType') event_type,
        ''lane_no, ''speed,
        get_json_object(list_json,'$.posX')  pos_x,
        get_json_object(list_json,'$.posY')  pos_y,
        ''brand,''source_image, ''source_num, ''source_type, ''source_url, ''direction_radar,
        ''congestion_grade,''target_count, ''lane_no_original, ''event_type_detail,
        get_json_object(list_json,'$.targetLen')  target_len,
        ''queue_len,''queue_count,'' pos_head,''pos_tail,
        date(t2.create_time) day
from ( select
       get_json_object(event_json,'$.id')             id,
       get_json_object(event_json,'$.deviceNo')       device_no,
       get_json_object(event_json,'$.createTime')     create_time,
       get_json_object(event_json,'$.objList')        obj_list
from hurys_dc_ods.ods_event) as t2
lateral view explode(split(regexp_replace(regexp_replace(obj_list,
                                                '\\[|\\]','') ,  
                                 '\\}\\,\\{','\\}\\;\\{'),  
                   '\\;') 
          )list_obj as list_json
where t2.obj_list is not null
group by t2.device_no, get_json_object(list_json,'$.id'), create_time, get_json_object(list_json,'$.eventType'), get_json_object(list_json,'$.posX'), get_json_object(list_json,'$.posY'), get_json_object(list_json,'$.targetLen'))
select
a2.id, device_no, create_time, event_type, lane_no, speed, pos_x, pos_y, brand, source_image, source_num, source_type, source_url, direction_radar, congestion_grade, target_count, lane_no_original, event_type_detail, target_len, queue_len, queue_count, pos_head, pos_tail, day
from a2;

六、检查新的SQL运行效果

org.apache.hadoop.hive.ql.parse.semanticexception:column id found in more th,Hive,hadoop,hive,数据仓库

执行成功!

虽然还是不清楚之前SQL报错的原因,但是换种方式能运行就行。

对于之前SQL报错的原因,如果大家知道的话还请告诉我,谢谢!

org.apache.hadoop.hive.ql.parse.SemanticException: Line 2:5 Ambiguous table alias 't2'

到了这里,关于二百零九、Hive——with嵌套语句报错:hadoop.hive.ql.parse.SemanticException: Line 2:5 Ambiguous table alias ‘t2‘的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • XUbuntu22.04之免费开源DesktopNaotu脑图(二百零七)

    简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长! 优质专栏: Audio工程师进阶系列 【 原创干货持续更新中…… 】🚀 优质专栏: 多媒体系统工程师系列 【 原创干货持续更新中…… 】🚀 人生格言: 人生从来没有捷径

    2024年01月16日
    浏览(27)
  • XUbuntu22.04之删除多余虚拟网卡和虚拟网桥(二百零四)

    简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长! 优质专栏: Audio工程师进阶系列 【 原创干货持续更新中…… 】🚀 优质专栏: 多媒体系统工程师系列 【 原创干货持续更新中…… 】🚀 人生格言: 人生从来没有捷径

    2024年02月04日
    浏览(37)
  • XUbuntu22.04之跨平台容器格式工具:MKVToolNix(二百零三)

    简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长! 优质专栏: Audio工程师进阶系列 【 原创干货持续更新中…… 】🚀 优质专栏: 多媒体系统工程师系列 【 原创干货持续更新中…… 】🚀 人生格言: 人生从来没有捷径

    2024年02月04日
    浏览(35)
  • PCL点云处理之最小二乘空间直线拟合(3D) (二百零二)

    对于空间中的这样一组点:大致呈直线分布,散乱分布在直线左右, 我们可采用最小二乘方法拟合直线,更进一步地,可以通过点到直线的投影,最终得到一组严格呈直线分布的点,同时,这个结果也可以验证最小二乘拟合得到的直线参数是否正确,使用下面的代码可以得到

    2024年02月12日
    浏览(32)
  • 架构设计内容分享(二百零一):什么是数据仓库的架构?企业数据仓库架构如何建设?

    目录 企业数据仓库架构 单层架构(直连) 两层数据架构(数据集市层) 三层架构(OLAP) 数据仓库数据库 1、采用传统关系型数据库,或经过功能扩展的MPP数据库 2、大数据平台架构:Hadoop+Hive 采集、收集、清洗和转换工具(ETL) 1、抽取 2、清洗 3、转化和加载 前端应用工具

    2024年02月21日
    浏览(33)
  • PCL点云处理之最小二乘直线拟合(2D| 方法2)(❤亲测可用❤)(二百零一)

    在二百章中,我们介绍了一种最小二乘拟合直线点云(2D)的方法,可以获取直线方程系数k,b,这里介绍另一种拟合直线点云的方法,更为简单方便,结果与前者一致,主要内容直接复制代码使用即可,原理简单看代码即可,下面是具体的实现和拟合结果展示 离散点云中拟合规

    2024年02月16日
    浏览(45)
  • 二百一十九、Hive——HQL报错:Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 1

    在海豚调度HQL的脚本任务时报错, Caused by: java.util.regex.PatternSyntaxException: Illegal repetition near index 1 with t1 as( select        get_json_object(queue_json,\\\'$.deviceNo\\\')   device_no,        get_json_object(queue_json,\\\'$.createTime\\\') create_time,        get_json_object(queue_json,\\\'$.laneNum\\\')    lane_num,        ge

    2024年02月01日
    浏览(43)
  • Hive报错org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask

    报错Error while compiling statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapredLocalTask 执行Hive两个表JOIN时出现如上错误 报错原因: 执行的join是大表和小表进性join,而Hive默认开启了MapJoin,即:hive.auto.convert.join=true; 但集群机器内存不够,导致出错。 Map Join

    2024年02月12日
    浏览(48)
  • Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop102:10000: Failed to open..

    在hive目录下使用beeline命令:  具体的报错信息如下所示: 22/04/10 01:13:24 [main]: WARN jdbc.HiveConnection: Failed to connect to hadoop102:10000 Error: Could not open client transport with JDBC Uri: jdbc:hive2://hadoop102:10000: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hado

    2024年02月11日
    浏览(52)
  • hive 报错return code 40000 from org.apache.hadoop.hive.ql.exec.MoveTask解决思路

    参考学习 https://github.com/apache/hive/blob/2b57dd27ad61e552f93817ac69313066af6562d9/ql/src/java/org/apache/hadoop/hive/ql/ErrorMsg.java#L47 为啥学习error code 开发过程中遇到以下错误,大家觉得应该怎么办?从哪方面入手呢? 1.百度? 2.源码查看报错地方 3.忽略(这个错是偶发的) 但是这个错是hive的错,

    2024年02月03日
    浏览(54)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包