Skip to content

Commit

Permalink
Set appname and add prefix for SQL Server session (#159)
Browse files Browse the repository at this point in the history
* Set the JDBC application name to "Spark MSSQL Connector" by default

The change also respects the case when the user passes in applicationName in the `options` Map.

* add prefix for sql server session app name

* modify the form of app name

Co-authored-by: Arvind Shyamsundar <arvindsh@apache.org>
  • Loading branch information
luxu1-ms and arvindshmicrosoft authored Jun 20, 2022
1 parent b26d953 commit 9a07172
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ class DefaultSource extends JdbcRelationProvider with Logging {
mode: SaveMode,
parameters: Map[String, String],
rawDf: DataFrame): BaseRelation = {
val options = new SQLServerBulkJdbcOptions(parameters)
// set SQL Server session application name to SparkMSSQLConnector:user input name
// if no user input app name provided, will use SparkMSSQLConnector:NotSpecified
val applicationName = s"SparkMSSQLConnector:${parameters.getOrElse("applicationname", "NotSpecified")}"
val options = new SQLServerBulkJdbcOptions(parameters + ("applicationname" -> applicationName))
val conn = createConnectionFactory(options)()
val df = repartitionDataFrame(rawDf, options)

Expand Down

0 comments on commit 9a07172

Please sign in to comment.