How to resolve the AnalysisException: resolved attribute(s) in Spark

后端 未结 12 892
故里飘歌
故里飘歌 2020-12-14 07:03
val rdd = sc.parallelize(Seq((\"vskp\", Array(2.0, 1.0, 2.1, 5.4)),(\"hyd\",Array(1.5, 0.5, 0.9, 3.7)),(\"hyd\", Array(1.5, 0.5, 0.9, 3.2)),(\"tvm\", Array(8.0, 2.9,         


        
12条回答
  •  一整个雨季
    2020-12-14 07:38

    In my case this error appeared during self join of same table. I was facing the below issue with Spark SQL and not the dataframe API:

    org.apache.spark.sql.AnalysisException: Resolved attribute(s) originator#3084,program_duration#3086,originator_locale#3085 missing from program_duration#1525,guid#400,originator_locale#1524,EFFECTIVE_DATETIME_UTC#3157L,device_timezone#2366,content_rpd_id#734L,originator_sublocale#2355,program_air_datetime_utc#3155L,originator#1523,master_campaign#735,device_provider_id#2352 in operator !Deduplicate [guid#400, program_duration#3086, device_timezone#2366, originator_locale#3085, originator_sublocale#2355, master_campaign#735, EFFECTIVE_DATETIME_UTC#3157L, device_provider_id#2352, originator#3084, program_air_datetime_utc#3155L, content_rpd_id#734L]. Attribute(s) with the same name appear in the operation: originator,program_duration,originator_locale. Please check if the right attribute(s) are used.;;
    

    Earlier I was using below query,

        SELECT * FROM DataTable as aext
                 INNER JOIN AnotherDataTable LAO 
    ON aext.device_provider_id = LAO.device_provider_id 
    

    Selecting only required columns before joining solved the issue for me.

          SELECT * FROM (
        select distinct EFFECTIVE_DATE,system,mso_Name,EFFECTIVE_DATETIME_UTC,content_rpd_id,device_provider_id 
    from DataTable 
    ) as aext
             INNER JOIN AnotherDataTable LAO ON aext.device_provider_id = LAO.device_provider_id 
    

提交回复
热议问题