cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
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
Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.