spark dataframe unionall
Posted 李克华
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spark dataframe unionall相关的知识,希望对你有一定的参考价值。
今天本来想写一个spark dataframe unionall的demo,由于粗心报下面错误:
Exception in thread "main" org.apache.spark.sql.AnalysisException: Union can only be performed on tables with the same number of columns, but the left table has 3 columns and the right has 4;
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$class.failAnalysis(CheckAnalysis.scala:38)
at org.apache.spark.sql.catalyst.analysis.Analyzer.failAnalysis(Analyzer.scala:44)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1.apply(CheckAnalysis.scala:170)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$$anonfun$checkAnalysis$1.apply(CheckAnalysis.scala:50)
at org.apache.spark.sql.catalyst.trees.TreeNode.foreachUp(TreeNode.scala:121)
at org.apache.spark.sql.catalyst.analysis.CheckAnalysis$class.checkAnalysis(CheckAnalysis.scala:50)
at org.apache.spark.sql.catalyst.analysis.Analyzer.checkAnalysis(Analyzer.scala:44)
at org.apache.spark.sql.execution.QueryExecution.assertAnalyzed(QueryExecution.scala:34)
at org.apache.spark.sql.DataFrame.<init>(DataFrame.scala:133)
at org.apache.spark.sql.DataFrame.org$apache$spark$sql$DataFrame$$withPlan(DataFrame.scala:2127)
at org.apache.spark.sql.DataFrame.unionAll(DataFrame.scala:1008)
at com.xiaoju.arch.engine.spark.ReadHiveDemo.main(ReadHiveDemo.java:74)
错误信息很简单:两张表union,至少字段保持一致吧,汗~~~~
以上是关于spark dataframe unionall的主要内容,如果未能解决你的问题,请参考以下文章