microsoft / sql-spark-connector

Apache Spark Connector for SQL Server and Azure SQL
Apache License 2.0
273 stars 116 forks source link

Connection Error: Only when using AD Password Mode #215

Open dinobm opened 1 year ago

dinobm commented 1 year ago

I am getting the following error while using the Spark Connector with the AD Password

value = OUTPUT_CONVERTER[type](answer[2:], gateway_client) 325 if answer[1] == REFERENCE_TYPE: --> 326 raise Py4JJavaError( 327 "An error occurred while calling {0}{1}{2}.\n". 328 format(target_id, ".", name), value)

Py4JJavaError: An error occurred while calling o2282.load. : java.lang.NoClassDefFoundError: com/nimbusds/oauth2/sdk/auth/ClientAuthentication

I have tried the connector with the SQL Auth (UID, Password, also with the Service Principal and Token they both work. So i am not sure, if this is because of the missing assembly referenced here(https://github.com/microsoft/sql-spark-connector/issues/26)

The code is being run from a Synapse Notebook. Any Ideas?

luxu1-ms commented 1 year ago

Could you share the repro?

dinobm commented 1 year ago

Here is a Snapshot of the code we use. This is used in a notebook (Synpase) agains the default Spark Cluster running Spark 3.2. The connector works if i use SQL Auth or the Service Principal/Token. Note the Sevrer is a Synapse Endpoint.

jdbc_df = spark.read.format("com.microsoft.sqlserver.jdbc.spark").option("url", "jdbc:sqlserver://Z-ondemand.sql.azuresynapse.net") \
.option("dbtable", "dbo.MyTable").option("authentication", "ActiveDirectoryPassword") \
.option("user","a@test.com").option("password", "XXXXXXXXXXXX").option("encrypt", "true")\
.option("hostNameInCertificate", "*.database.windows.net")\
.option("driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")\
.load()
luxu1-ms commented 1 year ago

I am not sure where the issue is from. Maybe check this and contact Synapse support.

dinobm commented 1 year ago

I have also reported this to the MS Q&A Forums. But the error seems to be in the Connector than with Synapse by itself. I wonder if anyone else has used AD/password approach at all. Anyways, i will post any update/solution i stumble upon.