Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0
    • 3.0.0
    • SQL
    • None

    Description

      Spark SQL:

      spark-sql> SELECT DIV(CAST(10 AS DECIMAL), CAST(3 AS DECIMAL));
      Error in query: cannot resolve '(CAST(10 AS DECIMAL(10,0)) div CAST(3 AS DECIMAL(10,0)))' due to data type mismatch: '(CAST(10 AS DECIMAL(10,0)) div CAST(3 AS DECIMAL(10,0)))' requires integral type, not decimal(10,0); line 1 pos 7;
      'Project [unresolvedalias((cast(10 as decimal(10,0)) div cast(3 as decimal(10,0))), None)]
      +- OneRowRelation
      

      PostgreSQL:

      postgres=# SELECT DIV(CAST(10 AS DECIMAL), CAST(3 AS DECIMAL));
       div
      -----
         3
      (1 row)
      

      Attachments

        Issue Links

          Activity

            yumwang Yuming Wang added a comment -

            cc mgaido

            yumwang Yuming Wang added a comment - cc mgaido
            yumwang Yuming Wang added a comment -

            DIV and / are a little different:

            select 12345678901234567890 / 123;
                  ?column?      
            --------------------
             100371373180768845
            (1 row)
            
            select div(12345678901234567890, 123);
                    div         
            --------------------
             100371373180768844
            (1 row)
            

            https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/numeric.out#L1564-L1574

            yumwang Yuming Wang added a comment - DIV and / are a little different: select 12345678901234567890 / 123; ? column ? -------------------- 100371373180768845 (1 row ) select div (12345678901234567890, 123); div -------------------- 100371373180768844 (1 row ) https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/numeric.out#L1564-L1574
            mgaido Marco Gaido added a comment -

            Thanks for pinging me yumwang, I'll work on this on the weekend. Thanks!

            mgaido Marco Gaido added a comment - Thanks for pinging me yumwang , I'll work on this on the weekend. Thanks!
            maropu Takeshi Yamamuro added a comment - Resolved by  https://github.com/apache/spark/pull/25136

            People

              mgaido Marco Gaido
              yumwang Yuming Wang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: