데이터 프레임 스파크 (2 DF의의 조합이다)를 DF에 적용 할 때 예상대로 작동하지 않습니다필터가
def unionByName(a: DataFrame, b: DataFrame): DataFrame = {
val columns = a.columns.toSet.intersect(b.columns.toSet).map(col).toSeq
a.select(columns: _*).unionAll(b.select(columns: _*))
}
결과는 : 데이터 프레임 C
아래 열 이름이 dataframes에 UnionAllSN Hash_id Name
111 11ww11 Airtel
222 null Idea
333 null BSNL
444 22ee11 Vodafone
데이터 프레임 c에서 필터를 수행합니다.
val withHashDF = c.where(c("Hash_id").isNotNull)
val withoutHashDF = c.where(c("Hash_id").isNull)
withHashDF
대한 결과는 다음
444 22ee11 Vodafone
: 단지 해시 ID가 존재 B가없는 데이터 프레임을 녹음합니다
111 11ww11 Airtel
프레임을 형성하는 데이터에 대한 결과를 얻을
에 대한 결과는
222 null Idea
BSNL 333 null
null 222 Idea
입니다.
이 DF에서 열 값은 열 이름과 같지 않으며 개수는 3이어야합니다. 2. 데이터 프레임 "a"행이 반복됩니다. unionByName
에서
정상적으로 작동합니다. unionByName 메서드가 호출 된 곳과 데이터 프레임 c가 채워지는 곳의 문제와 같습니다. –