hive表在hdp的spark2sql中不可访问

tf7tbtn2  于 2021-06-26  发布在  Hive
关注(0)|答案(2)|浏览(268)

我在hdp做以下工作。

export SPARK-MAJOR-VERSION=2 spark-submit --class com.spark.sparkexamples.Audit --master yarn --deploy-mode cluster \ --files /bigdata/datalake/app/config/metadata.csv BRNSAUDIT_v4.jar dl_raw.ACC /bigdatahdfs/landing/AUDIT/BW/2017/02/27/ACC_hash_total_and_count_20170227.dat TH 20170227

它的错误在于:
未找到表或视图: dl_raw . ACC ; 第1行位置94;'聚合[count(1)as rec#cnt#58l,'count('brch#num)as hashcount#59,'sum('acc#num)as hashsum#60]+-'过滤器('trim('country#code)=trim(th))&('fromŠunixtime('unixŠtimestamp('substr('busŠdate,0,11),mm/dd/yyyyyyymmdd)=20170227))+-'未解决的关系 dl_raw .`acc'*
而表是目前在Hive和它可以从Spark壳。
这是spark会话的代码。

val sparkSession = SparkSession.builder .appName("spark session example") .enableHiveSupport() .getOrCreate() 
sparkSession.conf.set("spark.sql.crossJoin.enabled", "true") 
val df_table_stats = sparkSession.sql("""select count(*) as rec_cnt,count(distinct BRCH_NUM) as hashcount, sum(ACC_NUM) as hashsum 
                                         from dl_raw.ACC 
                                         where trim(country_code) = trim('BW') 
                                         and from_unixtime(unix_timestamp(substr(bus_date,0,11),'MM/dd/yy‌​yy'),'yyyyMMdd')='20‌​170227'
                                      """)
disbfnqx

disbfnqx1#

提交spark作业时,在--files参数中包含hive-site.xml。

sg24os4d

sg24os4d2#

您还可以将hive-site.xml配置文件从hive conf dir复制到spark conf dir。这应该能解决你的问题。 cp /etc/hive/conf/hive-site.xml /etc/spark2/conf

相关问题