[MCOL-3518] float and double display ignores number of decimals Created: 2019-09-27  Updated: 2019-11-18  Resolved: 2019-11-18

Status: Closed
Project: MariaDB ColumnStore
Component/s: MDB Plugin
Affects Version/s: 1.4
Fix Version/s: 1.4.1

Type: Bug Priority: Major
Reporter: David Hall (Inactive) Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Sprint: 2019-06

 Description   

In 1.4, we lost modify access to Field_num::dec. We had been setting this to handle the proper display of values converted to double internally. Now we display things that should have fixed number of decimals with variable number of decimal.

A fix would be to do our own conversion to string type and return that for display.



 Comments   
Comment by David Hall (Inactive) [ 2019-10-31 ]

QA:
This bug has only been observed for regr_avgx and regr_avgy. Bad = unlimited (random) number of decimal points. Good = fixed decimal equal to the number of decimals in the argument + 4.

Example:
MariaDB [tpch1]> select avg(l_extendedprice), l_tax, regr_avgx(l_tax, l_extendedprice) from lineitem group by l_tax order by l_tax;
------------------------------------------------------------

avg(l_extendedprice) l_tax regr_avgx(l_tax, l_extendedprice)

------------------------------------------------------------

38241.598461 0.00 38241.598461
38283.541766 0.01 38283.541766
38250.487309 0.02 38250.487309
38259.281037 0.03 38259.281037
38247.196745 0.04 38247.196745
38234.848087 0.05 38234.848087
38246.434292 0.06 38246.434292
38281.196371 0.07 38281.196371
38251.623368 0.08 38251.623368

------------------------------------------------------------
9 rows in set (1.282 sec)

Note that the number of decimals for AVG and REGR_AVGX are 6, which is the two from l_extendedprice + 4. Before this patch AVG and REGR_AVGX would be different, with AVG being correct, but REGR_AVGX with possibly many more decimal places.

This did not affect 1.2, but is a regression due to convergence.

Similarly for REGR_AVGY:
MariaDB [tpch1]> select avg(l_extendedprice), l_tax, regr_avgy(l_tax, l_extendedprice) from lineitem group by l_tax order by l_tax;
------------------------------------------------------------

avg(l_extendedprice) l_tax regr_avgy(l_tax, l_extendedprice)

------------------------------------------------------------

38241.598461 0.00 0.000000
38283.541766 0.01 0.010000
38250.487309 0.02 0.020000
38259.281037 0.03 0.030000
38247.196745 0.04 0.040000
38234.848087 0.05 0.050000
38246.434292 0.06 0.060000
38281.196371 0.07 0.070000
38251.623368 0.08 0.080000

------------------------------------------------------------
9 rows in set (1.260 sec)

This takes the AVG of the Y (first) parameter. SInce l_tax has 2 decimal places defined, the result should have 6 decimal places.

Comment by Daniel Lee (Inactive) [ 2019-11-04 ]

Build tested: 1.4.1-1

[dlee@master tests]$ cat /data/qa/release/1.4.1-1/centos7/gitversionInfo.txt
engine commit:
3e7a964

When trying to run queries, I hit the following error:

select avg(l_extendedprice), l_tax, regr_avgx(l_tax, l_extendedprice) from lineitem group by l_tax order by l_tax;
ERROR 1305 (42000): FUNCTION tpch1.regr_avgx does not exist

I think this is the same issue as reported in other bugs. I will test again when the issue is fixed.

Comment by Daniel Lee (Inactive) [ 2019-11-18 ]

Build verfied: 1.4.1-1 github source

Server
commit 77a245fe5658b8d6d937620586ecd802b3432a78
Author: Marko Mäkelä <marko.makela@mariadb.com>
Date: Sun Nov 17 20:04:11 2019 +0200

Engine
commit 7c6a086cfb54b8bbd500efb41f34c9fa1ed03ca1
Merge: f291d88 1a94d53
Author: Roman Nozdrin <drrtuy@gmail.com>
Date: Mon Nov 18 12:11:30 2019 +0300

MariaDB [tpch1]> select avg(l_extendedprice), l_tax, regr_avgx(l_tax, l_extendedprice) from lineitem group by l_tax order by l_tax;
------------------------------------------------------------

avg(l_extendedprice) l_tax regr_avgx(l_tax, l_extendedprice)

------------------------------------------------------------

38241.598461 0.00 38241.598461
38283.541766 0.01 38283.541766
38250.487309 0.02 38250.487309
38259.281037 0.03 38259.281037
38247.196745 0.04 38247.196745
38234.848087 0.05 38234.848087
38246.434292 0.06 38246.434292
38281.196371 0.07 38281.196371
38251.623368 0.08 38251.623368

------------------------------------------------------------
9 rows in set (1.298 sec)

MariaDB [tpch1]> select avg(l_extendedprice), l_tax, regr_avgy(l_tax, l_extendedprice) from lineitem group by l_tax order by l_tax;
------------------------------------------------------------

avg(l_extendedprice) l_tax regr_avgy(l_tax, l_extendedprice)

------------------------------------------------------------

38241.598461 0.00 0.000000
38283.541766 0.01 0.010000
38250.487309 0.02 0.020000
38259.281037 0.03 0.030000
38247.196745 0.04 0.040000
38234.848087 0.05 0.050000
38246.434292 0.06 0.060000
38281.196371 0.07 0.070000
38251.623368 0.08 0.080000

------------------------------------------------------------
9 rows in set (1.220 sec)

Generated at Thu Feb 08 02:43:19 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.