우선, 제 질문을 읽어 주셔서 감사합니다.데이터 프레임 스파크 자바에 가입
제 질문은 다음과 같습니다. Spark with Java에서는 두 개의 데이터 프레임에 두 개의 CSV 파일 데이터를로드합니다.
이 데이터 프레임에는 다음과 같은 정보가 있습니다.
Dataframe 공항
Id | Name | City
-----------------------
1 | Barajas | Madrid
Dataframe의 airport_city_state 내가이 같이 보이도록이 두 dataframes에 가입 할
City | state
----------------
Madrid | España
:
dataframe 결과
Id | Name | City | state
--------------------------
1 | Barajas | Madrid | España
여기서 dfairport.city = dfaiport_city_state.city
하지만 올바르게 결합 할 수 있도록 구문을 명확히 할 수 없습니다. 어떻게 생성 한 변수의 작은 코드 : 당신은 열 이름으로 join
방법을 사용할 수 있습니다
// Load the csv, you have to specify that you have header and what delimiter you have
Dataset <Row> dfairport = Load.Csv (sqlContext, data_airport);
Dataset <Row> dfairport_city_state = Load.Csv (sqlContext, data_airport_city_state);
// Change the name of the columns in the csv dataframe to match the columns in the database
// Once they match the name we can insert them
Dfairport
.withColumnRenamed ("leg_key", "id")
.withColumnRenamed ("leg_name", "name")
.withColumnRenamed ("leg_city", "city")
dfairport_city_state
.withColumnRenamed("city", "ciudad")
.withColumnRenamed("state", "estado");