Skip to content
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

java.lang.NoSuchMethodError:$getSchema if I used truncate option is set to True #11

Open
Roy-Bosco opened this issue Feb 4, 2023 · 1 comment

Comments

@Roy-Bosco
Copy link

Py4JJavaError: An error occurred while calling o3400.save.
: java.lang.NoSuchMethodError: org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$.getSchema(Ljava/sql/ResultSet;Lorg/apache/spark/sql/jdbc/JdbcDialect;Z)Lorg/apache/spark/sql/types/StructType;

If I use Apache Spark sql connctor with "truncate" option is set to true it's throwing above error message. If I used truncate option false which drops the destination table and recreate with different schema: for example: char(2) will be set to nvarchar(max) in the destination sql table. Any recommendation to fix this issue.

@moredatapls
Copy link
Member

Py4JJavaError: An error occurred while calling o3400.save.

I am assuming that you're using Databricks? If so, the first exception you mentioned is a duplicate of #10. Unfortunately, there's not much we can do, it's a bug on Databricks from what I can tell.

drops the destination table and recreate with different schema

This is the intended behaviour if your column is of StringType. The schema of the DataFrame will be used to recreate the table, not the schema of the existing table.

The only option I see is that you try to manually truncate or drop/recreate your table using a JDBC connection and not through the SQL Spark connector. You could then append the data to the newly created/truncated table.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants