cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to fetch data from Simba Spark Jdbc Driver

Devaraj
New Contributor

We are getting below error when we tried to set the date in preparedstatement using Simba Spark Jdbc Driver.

Exception:

Query execution failed: [Simba][SparkJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: org.apache.hive.service.cli.HiveSQLException: Error running query: org.apache.spark.sql.AnalysisException: cannot resolve 'CAST(`col1` AS DATE)' due to data type mismatch: cannot cast int to date.

To convert values from int to date, you can use function DATE_FROM_UNIX_DATE instead.

; line 1 pos 0;

Code :

preparedstatement.setDate(java.sql.Date.of(dateFormatString))

DateFormat used to set is : 'yyyy-MM-dd'

Below is the generated sql resulting the error.

INSERT INTO TABLE

crud_test
.
dcdaeraver
VALUES ( 2021-06-01 , 'Tuesday' , 'June' , 'Q_2' , '2021' , 3 , 1 , 1 , 1 , TRUE , 'June 2021' , 'Q_2 2021' , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 ) , ( 2021-06-02 , 'Wednesday' , 'June' , 'Q_2' , '2021' , 4 , 1 , 1 , 1 , TRUE , 'June 2021' , 'Q_2 2021' , 2 , 2 , 2 , 1 , 1 , 1 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 , 1 , 2021-06-01 , 2021-06-03 )

0 REPLIES 0

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group