[MCOL-4413] ROUND() function might be a FLOOR() for DECIMAL arguments in some cases Created: 2020-11-26  Updated: 2022-04-16  Resolved: 2022-04-16

Status: Closed
Project: MariaDB ColumnStore
Component/s: ExeMgr, PrimProc
Affects Version/s: None
Fix Version/s: 6.3.1

Type: Bug Priority: Minor
Reporter: Roman Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: beginner-friendly

Issue Links:
Relates
relates to MCOL-641 Full DECIMAL support in ColumnStore Closed

 Description   

The code in Func_round::getIntVal() returns a floor() not a real round. This doesn't look right so one needs to test it.



 Comments   
Comment by Weijun Huang [ 2022-04-09 ]

I tried to test ROUND() with differnet situstions, but I did not find any issue.

==============================================================================
 
TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------
 
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 16000..16019
#
# Test Round() for different decimal
#
# Deciamal is 0
Select ROUND(3.05);
ROUND(3.05)
3
Select ROUND(3.15);
ROUND(3.15)
3
Select ROUND(3.25);
ROUND(3.25)
3
Select ROUND(3.35);
ROUND(3.35)
3
Select ROUND(3.45);
ROUND(3.45)
3
Select ROUND(3.50);
ROUND(3.50)
4
Select ROUND(3.65);
ROUND(3.65)
4
Select ROUND(3.75);
ROUND(3.75)
4
Select ROUND(3.85);
ROUND(3.85)
4
Select ROUND(3.95);
ROUND(3.95)
4
 
# Deciamal is 1
 
Select ROUND(3.05,1);
ROUND(3.05,1)
3.1
Select ROUND(3.15,1);
ROUND(3.15,1)
3.2
Select ROUND(3.25,1);
ROUND(3.25,1)
3.3
Select ROUND(3.35,1);
ROUND(3.35,1)
3.4
Select ROUND(3.45,1);
ROUND(3.45,1)
3.5
Select ROUND(3.55,1);
ROUND(3.55,1)
3.6
Select ROUND(3.65,1);
ROUND(3.65,1)
3.7
Select ROUND(3.75, 1);
ROUND(3.75, 1)
3.8
Select ROUND(3.85, 1);
ROUND(3.85, 1)
3.9
Select ROUND(3.95, 1);
ROUND(3.95, 1)
4.0
 
# Deciamal is 2
 
Select ROUND(3.055,2);
ROUND(3.055,2)
3.06
Select ROUND(3.155,2);
ROUND(3.155,2)
3.16
Select ROUND(3.255,2);
ROUND(3.255,2)
3.26
Select ROUND(3.355,2);
ROUND(3.355,2)
3.36
Select ROUND(3.455,2);
ROUND(3.455,2)
3.46
Select ROUND(3.555,2);
ROUND(3.555,2)
3.56
Select ROUND(3.655,2);
ROUND(3.655,2)
3.66
Select ROUND(3.755, 2);
ROUND(3.755, 2)
3.76
Select ROUND(3.855, 2);
ROUND(3.855, 2)
3.86
Select ROUND(3.955, 2);
ROUND(3.955, 2)
3.96
main.func_round                          [ pass ]      7
--------------------------------------------------------------------------
The servers were restarted 0 times
Spent 0.007 of 2 seconds executing testcases
 
Completed: All 1 tests were successful.

Comment by Jigao Luo [ 2022-04-16 ]

The Code seem right: https://github.com/mariadb-corporation/mariadb-columnstore-engine/blob/develop/utils/funcexp/func_round.cpp#L112

Comment by Roman [ 2022-04-16 ]

Thank you Weijun Huang and Jigao Luo for the research. JFYI The issue had been fixed but this Jira issue hadn't been closed. Thanks for the note.

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