抱歉,如果听起来含糊不清,但可以解释将现有数据帧"df"写入MySQL表的步骤吗,说"product_mysql",反之亦然。
请参阅这篇Databricks文章:使用JDBC连接到SQL数据库。
import org.apache.spark.sql.SaveMode
val df = spark.table("...")
println(df.rdd.partitions.length)
// given the number of partitions above, users can reduce the partition value by calling coalesce() or increase it by calling repartition() to manage the number of connections.
df.repartition(10).write.mode(SaveMode.Append).jdbc(jdbcUrl, "product_mysql", connectionProperties)