You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Mehant Baid (JIRA)" <ji...@apache.org> on 2014/06/05 20:37:01 UTC

[jira] [Updated] (DRILL-799) cast bigint to decimal adds values after decimal points

     [ https://issues.apache.org/jira/browse/DRILL-799?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mehant Baid updated DRILL-799:
------------------------------

    Attachment: DRILL-799.patch

> cast bigint to decimal adds values after decimal points
> -------------------------------------------------------
>
>                 Key: DRILL-799
>                 URL: https://issues.apache.org/jira/browse/DRILL-799
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Functions - Drill
>            Reporter: Chun Chang
>            Assignee: Mehant Baid
>         Attachments: DRILL-799.patch
>
>
> tested use git.commit.id.abbrev=5d7e3d3
> when casting bigint, we add values after decimal points:
> 0: jdbc:drill:schema=dfs> select c_bigint, cast(c_bigint as decimal(18,2)) from data where c_row = 9;
> +------------+------------+
> |  c_bigint  |   EXPR$1   |
> +------------+------------+
> | -4567890123456789 | -4567890123456789.12 |
> +------------+------------+
> 0: jdbc:drill:schema=dfs> explain plan for select c_bigint, cast(c_bigint as decimal(18,2)) from data where c_row = 9;
> +------------+------------+
> |    text    |    json    |
> +------------+------------+
> | ScreenPrel
>   ProjectPrel(c_bigint=[$2], EXPR$1=[CAST($2):DECIMAL(18, 2)])
>     FilterPrel(condition=[=(CAST($1):INTEGER, 9)])
>       ScanPrel(groupscan=[ParquetGroupScan [entries=[ReadEntryWithPath [path=maprfs:/user/root/mondrian/data]], selectionRoot=/user/root/mondrian/data, columns=[SchemaPath [`c_row`], SchemaPath [`c_bigint`]]]])
>  | {
>   "head" : {
>     "version" : 1,
>     "generator" : {
>       "type" : "ExplainHandler",
>       "info" : ""
>     },
>     "type" : "APACHE_DRILL_PHYSICAL",
>     "options" : [ ],
>     "resultMode" : "EXEC"
>   },
>   "graph" : [ {
>     "pop" : "parquet-scan",
>     "@id" : 1,
>     "entries" : [ {
>       "path" : "maprfs:/user/root/mondrian/data"
>     } ],
>     "storage" : {
>       "type" : "file",
>       "connection" : "maprfs:///",
>       "workspaces" : {
>         "default" : {
>           "location" : "/user/root/mondrian/",
>           "writable" : false,
>           "storageformat" : null
>         },
>         "home" : {
>           "location" : "/",
>           "writable" : false,
>           "storageformat" : null
>         },
>         "root" : {
>           "location" : "/",
>           "writable" : false,
>           "storageformat" : null
>         },
>         "tmp" : {
>           "location" : "/tmp",
>           "writable" : true,
>           "storageformat" : "csv"
>         }
>       },
>       "formats" : {
>         "psv" : {
>           "type" : "text",
>           "extensions" : [ "tbl" ],
>           "delimiter" : "|"
>         },
>         "csv" : {
>           "type" : "text",
>           "extensions" : [ "csv" ],
>           "delimiter" : ","
>         },
>         "tsv" : {
>           "type" : "text",
>           "extensions" : [ "tsv" ],
>           "delimiter" : "\t"
>         },
>         "parquet" : {
>           "type" : "parquet"
>         },
>         "json" : {
>           "type" : "json"
>         }
>       }
>     },
>     "format" : {
>       "type" : "parquet"
>     },
>     "columns" : [ "`c_row`", "`c_bigint`" ],
>     "selectionRoot" : "/user/root/mondrian/data"
>   }, {
>     "pop" : "filter",
>     "@id" : 2,
>     "child" : 1,
>     "expr" : "equal(cast( (`c_row` ) as INT ), 9) ",
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000
>   }, {
>     "pop" : "project",
>     "@id" : 3,
>     "exprs" : [ {
>       "ref" : "`c_bigint`",
>       "expr" : "`c_bigint`"
>     }, {
>       "ref" : "`EXPR$1`",
>       "expr" : "cast( (`c_bigint` ) as DECIMAL18(18, 2) )"
>     } ],
>     "child" : 2,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000
>   }, {
>     "pop" : "screen",
>     "@id" : 4,
>     "child" : 3,
>     "initialAllocation" : 1000000,
>     "maxAllocation" : 10000000000
>   } ]
> } |



--
This message was sent by Atlassian JIRA
(v6.2#6252)