sparksql使用mysql里的数据写sql时.spark.sql.AnalysisException: Table or view not found: `Score`; line 1 pos 1

异常

20/04/19 15:47:10 INFO SparkSqlParser: Parsing command: select stu.*  from  Student stu join Score sco  on stu.Sno=sco.Sno  and sco.Cno='3-105' and sco.Degree >(select  max(Degree) from Score where Sno='109' order by Degree desc)
Exception in thread "main" org.apache.spark.sql.AnalysisException: Table or view not found: `Score`; line 1 pos 130;
'Project [ArrayBuffer(stu).*]
+- 'Join Inner, (((Sno#0 = Sno#18) && (Cno#19 = 3-105)) && (Degree#20 > scalar-subquery#42 []))
   :  +- 'Sort ['Degree DESC NULLS LAST], true
   :     +- 'Project [unresolvedalias('max('Degree), None)]
   :        +- 'Filter ('Sno = 109)
   :           +- 'UnresolvedRelation `Score`
   :- SubqueryAlias stu
   :  +- SubqueryAlias student
   :     +- Relation[Sno#0,Sname#1,Ssex#2,Sbirthday#3,Class#4] JDBCRelation(Student) [numPartitions=1]
   +- SubqueryAlias sco
      +- SubqueryAlias score
         +- Relation[Sno#18,Cno#19,Degree#20] JDBCRelation(Score) [numPartitions=1]

原因 是语句有问题 在写子查询的时候,子查询返回的结果只能是一个值,返回了两个值


## 错误的

 spark.sql("select stu.*  from  Student stu join Score sco  on stu.Sno=sco.Sno  and sco.Cno='3-105' and sco.Degree >(select  max(Degree) from Score where Sno='109' order by Degree desc)").show()


## 正确的

//     spark.sql("select *  from   Score sco  where sco.Cno='3-105' and sco.Degree > (select  Degree from Score where Sno='109' and Cno='3-105')").show()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值