on-internet
← Community

How to specify sql dialect when creating spark dataframe from JDBC?

Stack Overflow ·

I'm having an issue reading data via custom JDBC with Spark. How would I go about overriding the SQL dialect inferred via JDBC URL? The database in question is Vitess (https://github.com/youtube/vitess) which runs a MySql variant, so I want to specify a mysql dialect. The JDBC URL begins with jdbc:vitess// Otherwise, the DataFrameReader is inferring a default dialect which uses """ as a quote identifier. As a result, queries via spark.read.jdbc get sent as select 'id', 'col2', col3', 'etc' from table instead of select id, col2, col3, etc from table ...which returns the string constants instead

Comments

Sign in or sign up to comment and upvote.

No comments yet.