Uploaded image for project: 'MariaDB ColumnStore'
  1. MariaDB ColumnStore
  2. MCOL-4462

CAST(varchar_expr AS DECIMAL(M,N)) returns a wrong result

Details

    Description

      DROP TABLE IF EXISTS t1;
      CREATE TABLE t1 (a VARCHAR(10)) ENGINE=ColumnStore;
      INSERT INTO t1 VALUES ('10.1');
      SELECT
        a,
        CAST(a AS DECIMAL(10,1)),
        CAST(a AS DECIMAL(10,2)),
        CAST(a AS DECIMAL(10,3))
      FROM t1;
      

      +------+--------------------------+--------------------------+--------------------------+
      | a    | CAST(a AS DECIMAL(10,1)) | CAST(a AS DECIMAL(10,2)) | CAST(a AS DECIMAL(10,3)) |
      +------+--------------------------+--------------------------+--------------------------+
      | 10.1 |                     10.1 |                    10.01 |                   10.001 |
      +------+--------------------------+--------------------------+--------------------------+
      

      Expected to get '10.10' and '10.100' in the third and the fourth column.

      Attachments

        Issue Links

          Activity

            bar Alexander Barkov created issue -
            bar Alexander Barkov made changes -
            Field Original Value New Value
            Description {code:sql}
            DROP TABLE IF EXISTS t1;
            CREATE TABLE t1 (a VARCHAR(10)) ENGINE=ColumnStore;
            INSERT INTO t1 VALUES ('10.1');
            SELECT
              a,
              CAST(a AS DECIMAL(10,1)),
              CAST(a AS DECIMAL(10,2)),
              CAST(a AS DECIMAL(10,3))
            FROM t1;
            {code}
            {noformat}
            +------+--------------------------+--------------------------+--------------------------+
            | a | CAST(a AS DECIMAL(10,1)) | CAST(a AS DECIMAL(10,2)) | CAST(a AS DECIMAL(10,3)) |
            +------+--------------------------+--------------------------+--------------------------+
            | 10.1 | 10.1 | 10.01 | 10.001 |
            +------+--------------------------+--------------------------+--------------------------+
            {noformat}
            {code:sql}
            DROP TABLE IF EXISTS t1;
            CREATE TABLE t1 (a VARCHAR(10)) ENGINE=ColumnStore;
            INSERT INTO t1 VALUES ('10.1');
            SELECT
              a,
              CAST(a AS DECIMAL(10,1)),
              CAST(a AS DECIMAL(10,2)),
              CAST(a AS DECIMAL(10,3))
            FROM t1;
            {code}
            {noformat}
            +------+--------------------------+--------------------------+--------------------------+
            | a | CAST(a AS DECIMAL(10,1)) | CAST(a AS DECIMAL(10,2)) | CAST(a AS DECIMAL(10,3)) |
            +------+--------------------------+--------------------------+--------------------------+
            | 10.1 | 10.1 | 10.01 | 10.001 |
            +------+--------------------------+--------------------------+--------------------------+
            {noformat}

            Expected to get '10.10' and '10.100' in the third and the fourth column.
            toddstoffel Todd Stoffel (Inactive) made changes -
            Rank Ranked higher
            toddstoffel Todd Stoffel (Inactive) made changes -
            Rank Ranked higher
            toddstoffel Todd Stoffel (Inactive) made changes -
            Rank Ranked higher
            toddstoffel Todd Stoffel (Inactive) made changes -
            Rank Ranked higher
            toddstoffel Todd Stoffel (Inactive) made changes -
            Fix Version/s 5.6.1 [ 25031 ]
            Fix Version/s 5.5.1 [ 25030 ]
            bar Alexander Barkov made changes -
            toddstoffel Todd Stoffel (Inactive) made changes -
            Rank Ranked higher
            bar Alexander Barkov made changes -
            bar Alexander Barkov made changes -
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            gdorman Gregory Dorman (Inactive) made changes -
            Affects Version/s All [ 25803 ]
            Affects Version/s 5.4.3 [ 25202 ]
            gdorman Gregory Dorman (Inactive) made changes -
            Labels tech_debt
            gdorman Gregory Dorman (Inactive) made changes -
            Fix Version/s 6.1.1 [ 25600 ]
            Fix Version/s 5.6.1 [ 25031 ]
            toddstoffel Todd Stoffel (Inactive) made changes -
            Affects Version/s All [ 25803 ]

            People

              bar Alexander Barkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.