Home > other >  How to implement Java sparkSession Dataset<Row> Update the carbondata result set data model
How to implement Java sparkSession Dataset<Row> Update the carbondata result set data model

Time:09-19

Be sad etSparkSession chtistina georgina rossetti.british poetess in Java SparkSession SparkSession=();
SparkSession query:
Sb. Append (" SELECT base_user. Uuid AS owner_id, base_user. Name AS owner_name, base_user. Sex AS sex, "
+ "base_user. Birth AS birth, base_user nation AS nation, base_user. Origin AS origin, base_user.com pany AS company, COALESCE (car car_totalassets, 0) AS car_totalassets,"
+ "COALESCE (house. Estate_totalassets, 0) AS estate_totalassets, house. First_estate_date,"
+ ", now () AS analysis_time base_user iden_type, base_user. Iden_num, base_user. Delete_flag, ");
Sb. Append (SQL);
Sb. Append (" the FROM MDC. Base_user AS base_user "
+ "LEFT the JOIN (SELECT owner_id, COUNT (owner_id) AS car_totalassets FROM PLC. Park_car AS park_car WHERE park_car. Delete_flag=1
"+ "GROUP BY owner_id) AS the car ON the car. Owner_id=base_user. Uuid LEFT JOIN (SELECT user_uuid, MIN (create_time) AS first_estate_date,"
+ "COUNT (user_uuid) AS estate_totalassets FROM MDC. Base_house_user_rel AS base_house_user_rel WHERE base_house_user_rel. Delete_flag=1"
+ "GROUP BY user_uuid) AS house ON house. User_uuid=base_user. Uuid LEFT JOIN"
+ "op. Owner_portrait_info AS owner_portrait_info ON owner_portrait_info. Owner_id=base_user. Uuid WHERE"
+ "base_user. Delete_flag=1");
Through the results of the query to a dataset, Dataset Da=sparkSession. SQL (sb. ToString ());
Integrates carbondata,
Now I want to update the carbondata this result in the relational database, similar to this: sparkSession. SQL (" update op. Owner_portrait_info set (owner_name)=(' test1) where id=?" ); How to implement the Dataset of batch updates, is there anyone good implementation approach?

CodePudding user response:

DataFrame. Write. JDBC (), remember to put the JDBC driver in spark/jars directory
  • Related