You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The scalar functions sys.degrees(rad) and sys.radians(deg) are currently implemented as SQL system functions (in sql/scripts/10_math.sql).
CREATE FUNCTION degrees(r double) RETURNS double RETURN r180/pi();
CREATE FUNCTION radians(d double) RETURNS double RETURN dpi()/180;
This implies that when using them from any schema other than sys, you must include the sys. prefix, else you get an error.
Error: SELECT: no such unary operator 'degrees(decimal)'
Error: SELECT: no such unary operator 'radians(decimal)'
It would be more user friendly if this sys. prefix in SQL queries would not be needed, as is the case with all the other trigonometric functions.
This can be achieved by implementing the function logic in C (as done for sin(x), cos(x)) and removing the SQL implementation.
Possibly the native C implementations would also be faster and more efficient (less overhead).
Reproducible: Always
Steps to Reproduce:
select current_schema;
-- sys
set schema profiler;
select current_schema;
-- profiler
select degrees(0.5);
-- SELECT: no such unary operator 'degrees(decimal)'
select degrees(2);
-- SELECT: no such unary operator 'degrees(tinyint)'
select radians(45.0);
-- SELECT: no such unary operator 'radians(decimal)'
select sys.degrees(0.5), sys.degrees(2), sys.radians(45);
Date: 2020-06-03 11:09:42 +0200
From: Martin van Dinther <<martin.van.dinther>>
Further optimizations possible:
180/pi() can be replaced with constant: 57.295779513082320876798154814105
pi()/180 can be replaced with constant: 0.01745329251994329576923690768489
Date: 2020-01-29 17:28:54 +0100
From: Martin van Dinther <<martin.van.dinther>>
To: SQL devs <>
Version: 11.35.9 (Nov2019-SP1)
CC: @PedroTadim
Last updated: 2020-10-19 11:06:19 +0200
Comment 27531
Date: 2020-01-29 17:28:54 +0100
From: Martin van Dinther <<martin.van.dinther>>
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0
Build Identifier:
The scalar functions sys.degrees(rad) and sys.radians(deg) are currently implemented as SQL system functions (in sql/scripts/10_math.sql).
CREATE FUNCTION degrees(r double) RETURNS double RETURN r180/pi();
CREATE FUNCTION radians(d double) RETURNS double RETURN dpi()/180;
This implies that when using them from any schema other than sys, you must include the sys. prefix, else you get an error.
Error: SELECT: no such unary operator 'degrees(decimal)'
Error: SELECT: no such unary operator 'radians(decimal)'
It would be more user friendly if this sys. prefix in SQL queries would not be needed, as is the case with all the other trigonometric functions.
This can be achieved by implementing the function logic in C (as done for sin(x), cos(x)) and removing the SQL implementation.
Possibly the native C implementations would also be faster and more efficient (less overhead).
Reproducible: Always
Steps to Reproduce:
select current_schema;
-- sys
set schema profiler;
select current_schema;
-- profiler
select degrees(0.5);
-- SELECT: no such unary operator 'degrees(decimal)'
select degrees(2);
-- SELECT: no such unary operator 'degrees(tinyint)'
select radians(45.0);
-- SELECT: no such unary operator 'radians(decimal)'
select sys.degrees(0.5), sys.degrees(2), sys.radians(45);
Actual Results:
sql>select current_schema;
+------+
| L2 |
+======+
| sys |
+------+
1 tuple
sql>set schema profiler;
operation successful
sql>select current_schema;
+----------+
| L2 |
+==========+
| profiler |
+----------+
1 tuple
sql>select degrees(0.5);
SELECT: no such unary operator 'degrees(decimal)'
sql>select degrees(2);
SELECT: no such unary operator 'degrees(tinyint)'
sql>select radians(45.0);
SELECT: no such unary operator 'radians(decimal)'
sql>select sys.degrees(0.5), sys.degrees(2), sys.radians(45);
+--------------------------+--------------------------+--------------------------+
| L2 | L4 | L6 |
+==========================+==========================+==========================+
| 28.64788975654116 | 114.59155902616465 | 0.7853981633974483 |
+--------------------------+--------------------------+--------------------------+
1 tuple
Expected Results:
Allow functions degrees() and radians() to be called without sys. prefix when current schema is not sys.
Comment 27605
Date: 2020-03-17 20:12:28 +0100
From: Martin van Dinther <<martin.van.dinther>>
See also https://www.monetdb.org/bugzilla/show_bug.cgi?id=3553
Comment 27780
Date: 2020-06-03 11:09:42 +0200
From: Martin van Dinther <<martin.van.dinther>>
Further optimizations possible:
180/pi() can be replaced with constant: 57.295779513082320876798154814105
pi()/180 can be replaced with constant: 0.01745329251994329576923690768489
Comment 27871
Date: 2020-06-23 09:27:37 +0200
From: MonetDB Mercurial Repository <>
Changeset 4c270abe4e2d made by Pedro Ferreira pedro.ferreira@monetdbsolutions.com in the MonetDB repo, refers to this bug.
For complete details, see https//devmonetdborg/hg/MonetDB?cmd=changeset;node=4c270abe4e2d
Changeset description:
The text was updated successfully, but these errors were encountered: