Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-261

Implement support for DECIMAL type

    XMLWordPrintableJSON

Details

    • Task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 0.4.0
    • None
    • None

    Description

      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:

      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
      

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

      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;
      

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

      Attachments

        Activity

          People

            Unassigned Unassigned
            benjamin.becker Ben Becker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: