Not able to fetch data from Simba Spark Jdbc Driver
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2021 11:22 PM
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 )