Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21392

Cleanup redundant overriding in Item_sum_num

    XMLWordPrintable

Details

    Description

      Item_sum_num has features of DOUBLE data type by default and implements DOUBLE-applicable methods:

      • val_int()
      • val_str()
      • val_decimal()

      These methods then are overriden to INT-applicable and hybrid-applicable as follows:

      • Item_sum_int overrides these methods to INT-applicable.
      • Item_sum_window_with_row_count derives DOUBLE-applicable implementations from Item_sum_num.
      • Item_sum_ntile derives DOUBLE-applicable implementations from Item_sum_window_with_row_count and overrides val_real() to INT-based implementation. Note, Item_sum_ntile does not override val_decimal() and val_str(), which looks wrong because they work through val_real() by default and therefore may return truncated results on a huge data sets.
      • Item_sum_cume_dist derives from Item_sum_window_with_row_count.
      • Item_sum_percentile_disc derives from Item_sum_cume_dist and Type_handler_hybrid_field_type and overrides value methods to hybrid-applicable, except get_date().
      • Item_sum_percentile_cont derives from Item_sum_cume_dist and Type_handler_hybrid_field_type, but in fact it can olny have the DOUBLE data type.

      This multiple overriding is hard to follow. Let's introduce a new abstract class Item_sum_double and change the Item_sum_num hierarchy as follows:

      Item_sum_num
        Item_sum_percentile_disc  -- hybrid type
        Item_sum_sum              -- hybrid type
          Item_sum_avg
        Item_sum_double           -- DOUBLE
          Item_sum_percent_rank
          Item_sum_cume_dist
          Item_sum_percentile_cont
          Item_sum_variance
            Item_sum_std
          Item_sum_udf_float
          Item_sum_udf_int
          Item_sum_udf_decimal
          Item_sum_udf_str
        Item_sum_int              -- INT
          Item_sum_row_number
          Item_sum_rank
          Item_sum_dense_rank
          Item_sum_ntile
          Item_sum_count
          Item_sum_bit
            Item_sum_or
            Item_sum_and
            Item_sum_xor
      

      so that the method type_handler() and value methods like val_int(), val_real(), val_decimal(), get_date() are implemented inside the same class, without multiple nested overriding.

      Attachments

        Issue Links

          Activity

            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.