Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-13772

DataType mismatch about decimal

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.6.0
    • Fix Version/s: 1.6.2
    • Component/s: SQL
    • Labels:
      None
    • Environment:

      spark1.6.0 hadoop2.2.0 jdk1.7.0_79

    • Target Version/s:

      Description

      Code snippet to reproduce this issue using 1.6.0:

      select if(1=1, cast(1 as double), cast(1.1 as decimal) as a from test
      

      It will throw exceptions like this:

      Error in query: cannot resolve 'if ((1 = 1)) cast(1 as double) else cast(1.1 as decimal(10,0))' due to data type mismatch: differing types in 'if ((1 = 1)) cast(1 as double) else cast(1.1 as decimal(10,0))' (double and decimal(10,0)).; line 1 pos 37
      

      I also tested:

      select if(1=1,cast(1 as decimal),cast(1 as decimal(19,6))) from test;
      
      Error in query: cannot resolve 'if ((1 = 1)) cast(1 as decimal(10,0)) else cast(1 as decimal(19,6))' due to data type mismatch: differing types in 'if ((1 = 1)) cast(1 as decimal(10,0)) else cast(1 as decimal(19,6))' (decimal(10,0) and decimal(19,6)).; line 1 pos 38
      

        Attachments

          Activity

            People

            • Assignee:
              cenyuhai cen yuhai
              Reporter:
              cenyuhai cen yuhai
              Shepherd:
              Cheng Lian
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: