Ben Becker created DRILL-261:
--------------------------------

             Summary: Implement support for DECIMAL type
                 Key: DRILL-261
                 URL: https://issues.apache.org/jira/browse/DRILL-261
             Project: Apache Drill
          Issue Type: Task
            Reporter: Ben Becker


Many functions and operators in Drill need to handle decimal types.  This may 
mean two formats; an expanded format for use during processing, and a compact 
format for efficient representation on disk.

Postgres' compact (on-disk) format for the decimal types NumericShort and 
NumericLong generally fit into a 64 bits:

{noformat}
1 bit for sign
6 bits for scale  in NumericShort; 16 bits in NumericLong
7 bits for weight in NumericShort; 16 bits in NumericLong
16 bits for the digits
{noformat}

The expanded (in-memory) format in Postgres is defined in {{numeric.c}} as 
follows:

{noformat}
typedef struct NumericVar
{
        int ndigits;    /* # of digits in digits[] - can be 0! */
        int weight;     /* weight of first digit */
        int sign;       /* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
        int dscale;     /* display scale */
        NumericDigit *buf;      /* start of palloc'd space for digits[] */
        NumericDigit *digits;   /* base-NBASE digits */
} NumericVar;
{noformat}

Additional notes and links to related published papers are in the 
aforementioned source file.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to