in src/main/java/com/uber/uberscriptquery/util/SparkUtils.java [209:225]
public static void writeJdbc(Dataset<Row> df, String jdbcUrl, String tableName, List<String> primaryKeys, List<String> indexColumns, List<String> textColumns, SaveMode saveMode, String postWriteSql, double writesPerSecond) {
logger.info(String.format("Saving to jdbc table %s, saveMode: %s", tableName, saveMode));
String jdbcDriver = SqlUtils.loadJdbcDriverClass(jdbcUrl);
try {
DriverManager.getConnection(jdbcUrl).close();
} catch (SQLException e) {
throw new RuntimeException("Failed to open jdbc connection", e);
}
org.apache.spark.sql.execution.datasources.jdbc.DriverRegistry.register(com.mysql.jdbc.Driver.class.getName());
Properties properties = new Properties();
properties.put("driver", jdbcDriver);
(new DataFrameJdbcWriter(df)).mode(saveMode).jdbc(jdbcUrl, tableName, primaryKeys, indexColumns, textColumns, postWriteSql, writesPerSecond, properties);
logger.info(String.format("Saved to jdbc table %s, saveMode: %s", tableName, saveMode));
}