How to set jdbc/partitionColumn type to Date in spark 2.4.1

后端 未结 4 1942
清歌不尽
清歌不尽 2021-01-05 20:14

I am trying to retrieve data from oracle using spark-sql-2.4.1 version. I tried to set the JdbcOptions as below :

    .option(\"lowerBound\", \"31-MAR-02\");         


        
4条回答
  •  难免孤独
    2021-01-05 20:21

    I stumbled on this question as I am solving a similar problem. But in this case Spark 2.4.2 is sending date in format 'yyyy-MM-dd HH:mm:ss.ssss' to Oracle and it returned "Not a valid month" as it expects 'dd-MMM-yy HH:mm:ss.ssss'. To solve that I followed: Spark GitHub Link , it says:

    Override beforeFetch method in OracleDialect to finish the following two things:

    Set Oracle's NLS_TIMESTAMP_FORMAT to "YYYY-MM-DD HH24:MI:SS.FF" to match java.sql.Timestamp format. Set Oracle's NLS_DATE_FORMAT to "YYYY-MM-DD" to match java.sql.Date format.

    And it solved the issue. Hope it helps.

提交回复
热议问题