
Type: Task

Status: Closed (View Workflow)

Priority: Major

Resolution: Fixed

Component/s: Data types

Labels:None
Item_sum_num has features of DOUBLE data type by default and implements DOUBLEapplicable methods:
 val_int()
 val_str()
 val_decimal()
These methods then are overriden to INTapplicable and hybridapplicable as follows:
 Item_sum_int overrides these methods to INTapplicable.
 Item_sum_window_with_row_count derives DOUBLEapplicable implementations from Item_sum_num.
 Item_sum_ntile derives DOUBLEapplicable implementations from Item_sum_window_with_row_count and overrides val_real() to INTbased 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 hybridapplicable, 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.
 blocks

MDEV21071 Data type cleanups
 Open
 relates to

MDEV4912 Data type plugin API version 1
 Closed

MDEV20280 PERCENTILE_DISC() rejects temporal and string input
 Closed