Commit f3d4fec4 authored by 王志伟's avatar 王志伟

测试训练数据写入

parent 6b5a2b20
......@@ -699,6 +699,8 @@ object tag_value {
|from level3_id
""".stripMargin
)
level_value.createOrReplaceTempView("tagId_value")
// tag_value.show(300)
println("开始写入")
......@@ -724,16 +726,34 @@ object tag_value {
val result = level_index_temp.select("tag_id").distinct().rdd.map{x => x.toString().substring(1,x.toString().length - 1)}.zipWithIndex().toDF("level_id","index_id")
val test=result.select(result.col("level_id").cast(DoubleType).as("level_id"),result.col("index_id").cast(DoubleType).as("index_id"))
test.createOrReplaceTempView("tag_level_index")
// val resDf = spark.createDataFrame(rowRdd)
println("开始写入")
GmeiConfig.writeToJDBCTable("jdbc:mysql://172.16.40.158:4000/jerry_prod?user=root&password=3SYz54LS9#^9sBvC&rewriteBatchedStatements=true",test, table="tag_level_index",SaveMode.Overwrite)
println("写入完成")
// zhengxing库里面的数据同步到jerry_prod
val icon_today_train_data=sc.sql(
s"""
|select a.device_id,c.index_id as index_id,b.value from icon_train_data a
|left join tagId_value b on a.tag_id=b.level_id
|left join tag_level_index c on a.tag_id=c.level_id
|where c.index_id is not null and b.value is not null
""".stripMargin
)
println("开始写入")
GmeiConfig.writeToJDBCTable("jdbc:mysql://172.16.40.158:4000/jerry_prod?user=root&password=3SYz54LS9#^9sBvC&rewriteBatchedStatements=true",icon_today_train_data, table="icon_today_train_data_test",SaveMode.Overwrite)
println("写入完成")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment