-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connection closed when try to use om.microsoft.sqlserver.jdbc.spark connector #247
Comments
I'm getting the same error using: I can see the table itself is created before the error with columns in it Standard JDBC is working but processed only 2M rows in 2 hours |
I found the problem on my side, so please check it on yours. Best Regards, |
Interesting, I am going to play around at bit with the datatypes. The weird thing is that I was creating a new table without specifying any datatypes. Probably should because with the standard JDBC all strings become nvarchar(max) Just creating a new table using this: df.write |
For anyone interested, we faced similar issue recently and the solution is to recast the datatypes on PySpark DataFrame. It looks like that for some reason, the write to SQL works more reliable with strong casting. We added this step before every write in ETL pipelines.
If you use |
Hi, I try to write a row from Azure Databricks (11.3 LTS (includes Apache Spark 3.3.0, Scala 2.12) ) to Azure SQL DB using com.microsoft.azure:spark-mssql-connector_2.12:1.3.0-BETA library but unfortunately receive the following error:
23/12/08 17:29:56 ERROR Executor: Exception in task 0.3 in stage 198.0 (TID ...) com.microsoft.sqlserver.jdbc.SQLServerException: The connection is closed.
Below is the part from the code where I invoke Dataframe writing. The service principle has a db_owner database role.
if "access_token" in token:
access_token = token["access_token"]
result = df.write
.format("com.microsoft.sqlserver.jdbc.spark")
.option("url", the_sql_url)
.option("dbtable", f"staging.test_table")
.option("accessToken", access_token)
.mode("overwrite")
.save()
else:
raise ValueError("Failed to obtain an access token.")
At the same time, I do not have such a problem when I use the JDBC connector.
Would anyone be able to help me or at the current moment I can only use JDBC connector?
Thank you,
Roza
The text was updated successfully, but these errors were encountered: