diff --git a/edb/lib/math.edgeql b/edb/lib/math.edgeql index d3d57e32bffc..bd9ebb7cc3dc 100644 --- a/edb/lib/math.edgeql +++ b/edb/lib/math.edgeql @@ -16,11 +16,11 @@ # limitations under the License. # -CREATE MODULE math; +CREATE MODULE std::math; CREATE FUNCTION -math::abs(x: std::anyreal) -> std::anyreal +std::math::abs(x: std::anyreal) -> std::anyreal { CREATE ANNOTATION std::description := 'Return the absolute value of the input *x*.'; @@ -30,7 +30,7 @@ math::abs(x: std::anyreal) -> std::anyreal CREATE FUNCTION -math::ceil(x: std::int64) -> std::int64 +std::math::ceil(x: std::int64) -> std::int64 { CREATE ANNOTATION std::description := 'Round up to the nearest integer.'; SET volatility := 'Immutable'; @@ -39,7 +39,7 @@ math::ceil(x: std::int64) -> std::int64 CREATE FUNCTION -math::ceil(x: std::float64) -> std::float64 +std::math::ceil(x: std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Round up to the nearest integer.'; SET volatility := 'Immutable'; @@ -48,7 +48,7 @@ math::ceil(x: std::float64) -> std::float64 CREATE FUNCTION -math::ceil(x: std::bigint) -> std::bigint +std::math::ceil(x: std::bigint) -> std::bigint { CREATE ANNOTATION std::description := 'Round up to the nearest integer.'; SET volatility := 'Immutable'; @@ -57,7 +57,7 @@ math::ceil(x: std::bigint) -> std::bigint CREATE FUNCTION -math::ceil(x: std::decimal) -> std::decimal +std::math::ceil(x: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Round up to the nearest integer.'; SET volatility := 'Immutable'; @@ -66,7 +66,7 @@ math::ceil(x: std::decimal) -> std::decimal CREATE FUNCTION -math::floor(x: std::int64) -> std::int64 +std::math::floor(x: std::int64) -> std::int64 { CREATE ANNOTATION std::description := 'Round down to the nearest integer.'; SET volatility := 'Immutable'; @@ -75,7 +75,7 @@ math::floor(x: std::int64) -> std::int64 CREATE FUNCTION -math::floor(x: std::float64) -> std::float64 +std::math::floor(x: std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Round down to the nearest integer.'; SET volatility := 'Immutable'; @@ -84,7 +84,7 @@ math::floor(x: std::float64) -> std::float64 CREATE FUNCTION -math::floor(x: std::bigint) -> std::bigint +std::math::floor(x: std::bigint) -> std::bigint { CREATE ANNOTATION std::description := 'Round down to the nearest integer.'; SET volatility := 'Immutable'; @@ -93,7 +93,7 @@ math::floor(x: std::bigint) -> std::bigint CREATE FUNCTION -math::floor(x: std::decimal) -> std::decimal +std::math::floor(x: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Round down to the nearest integer.'; SET volatility := 'Immutable'; @@ -102,7 +102,7 @@ math::floor(x: std::decimal) -> std::decimal CREATE FUNCTION -math::ln(x: std::int64) -> std::float64 +std::math::ln(x: std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the natural logarithm of the input value.'; @@ -112,7 +112,7 @@ math::ln(x: std::int64) -> std::float64 CREATE FUNCTION -math::ln(x: std::float64) -> std::float64 +std::math::ln(x: std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the natural logarithm of the input value.'; @@ -122,7 +122,7 @@ math::ln(x: std::float64) -> std::float64 CREATE FUNCTION -math::ln(x: std::decimal) -> std::decimal +std::math::ln(x: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the natural logarithm of the input value.'; @@ -132,7 +132,7 @@ math::ln(x: std::decimal) -> std::decimal CREATE FUNCTION -math::lg(x: std::int64) -> std::float64 +std::math::lg(x: std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the base 10 logarithm of the input value.'; @@ -142,7 +142,7 @@ math::lg(x: std::int64) -> std::float64 CREATE FUNCTION -math::lg(x: std::float64) -> std::float64 +std::math::lg(x: std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the base 10 logarithm of the input value.'; @@ -152,7 +152,7 @@ math::lg(x: std::float64) -> std::float64 CREATE FUNCTION -math::lg(x: std::decimal) -> std::decimal +std::math::lg(x: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the base 10 logarithm of the input value.'; @@ -162,7 +162,7 @@ math::lg(x: std::decimal) -> std::decimal CREATE FUNCTION -math::log(x: std::decimal, NAMED ONLY base: std::decimal) -> std::decimal +std::math::log(x: std::decimal, NAMED ONLY base: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the logarithm of the input value in the specified *base*.'; @@ -174,7 +174,7 @@ math::log(x: std::decimal, NAMED ONLY base: std::decimal) -> std::decimal CREATE FUNCTION -math::sqrt(x: std::int64) -> std::float64 +std::math::sqrt(x: std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the square root of the input value.'; @@ -184,7 +184,7 @@ math::sqrt(x: std::int64) -> std::float64 CREATE FUNCTION -math::sqrt(x: std::float64) -> std::float64 +std::math::sqrt(x: std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the square root of the input value.'; @@ -194,7 +194,7 @@ math::sqrt(x: std::float64) -> std::float64 CREATE FUNCTION -math::sqrt(x: std::decimal) -> std::decimal +std::math::sqrt(x: std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the square root of the input value.'; @@ -202,12 +202,12 @@ math::sqrt(x: std::decimal) -> std::decimal USING SQL FUNCTION 'sqrt'; }; -# math::mean +# std::math::mean # ----------- # The mean function returns an empty set if the input is empty set. On # all other inputs it returns the mean for that input set. CREATE FUNCTION -math::mean(vals: SET OF std::decimal) -> std::decimal +std::math::mean(vals: SET OF std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the arithmetic mean of the input set.'; @@ -219,7 +219,7 @@ math::mean(vals: SET OF std::decimal) -> std::decimal CREATE FUNCTION -math::mean(vals: SET OF std::int64) -> std::float64 +std::math::mean(vals: SET OF std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the arithmetic mean of the input set.'; @@ -233,7 +233,7 @@ math::mean(vals: SET OF std::int64) -> std::float64 CREATE FUNCTION -math::mean(vals: SET OF std::float64) -> std::float64 +std::math::mean(vals: SET OF std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the arithmetic mean of the input set.'; @@ -244,10 +244,10 @@ math::mean(vals: SET OF std::float64) -> std::float64 }; -# math::stddev +# std::math::stddev # ------------ CREATE FUNCTION -math::stddev(vals: SET OF std::decimal) -> std::decimal +std::math::stddev(vals: SET OF std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the sample standard deviation of the input set.'; @@ -259,7 +259,7 @@ math::stddev(vals: SET OF std::decimal) -> std::decimal CREATE FUNCTION -math::stddev(vals: SET OF std::int64) -> std::float64 +std::math::stddev(vals: SET OF std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the sample standard deviation of the input set.'; @@ -273,7 +273,7 @@ math::stddev(vals: SET OF std::int64) -> std::float64 CREATE FUNCTION -math::stddev(vals: SET OF std::float64) -> std::float64 +std::math::stddev(vals: SET OF std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the sample standard deviation of the input set.'; @@ -284,10 +284,10 @@ math::stddev(vals: SET OF std::float64) -> std::float64 }; -# math::stddev_pop +# std::math::stddev_pop # ---------------- CREATE FUNCTION -math::stddev_pop(vals: SET OF std::decimal) -> std::decimal +std::math::stddev_pop(vals: SET OF std::decimal) -> std::decimal { CREATE ANNOTATION std::description := 'Return the population standard deviation of the input set.'; @@ -299,7 +299,7 @@ math::stddev_pop(vals: SET OF std::decimal) -> std::decimal CREATE FUNCTION -math::stddev_pop(vals: SET OF std::int64) -> std::float64 +std::math::stddev_pop(vals: SET OF std::int64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the population standard deviation of the input set.'; @@ -313,7 +313,7 @@ math::stddev_pop(vals: SET OF std::int64) -> std::float64 CREATE FUNCTION -math::stddev_pop(vals: SET OF std::float64) -> std::float64 +std::math::stddev_pop(vals: SET OF std::float64) -> std::float64 { CREATE ANNOTATION std::description := 'Return the population standard deviation of the input set.'; @@ -324,10 +324,10 @@ math::stddev_pop(vals: SET OF std::float64) -> std::float64 }; -# math::var +# std::math::var # -------------- CREATE FUNCTION -math::var(vals: SET OF std::decimal) -> OPTIONAL std::decimal +std::math::var(vals: SET OF std::decimal) -> OPTIONAL std::decimal { CREATE ANNOTATION std::description := 'Return the sample variance of the input set.'; @@ -339,7 +339,7 @@ math::var(vals: SET OF std::decimal) -> OPTIONAL std::decimal CREATE FUNCTION -math::var(vals: SET OF std::int64) -> OPTIONAL std::float64 +std::math::var(vals: SET OF std::int64) -> OPTIONAL std::float64 { CREATE ANNOTATION std::description := 'Return the sample variance of the input set.'; @@ -353,7 +353,7 @@ math::var(vals: SET OF std::int64) -> OPTIONAL std::float64 CREATE FUNCTION -math::var(vals: SET OF std::float64) -> OPTIONAL std::float64 +std::math::var(vals: SET OF std::float64) -> OPTIONAL std::float64 { CREATE ANNOTATION std::description := 'Return the sample variance of the input set.'; @@ -364,10 +364,10 @@ math::var(vals: SET OF std::float64) -> OPTIONAL std::float64 }; -# math::var_pop +# std::math::var_pop # ------------- CREATE FUNCTION -math::var_pop(vals: SET OF std::decimal) -> OPTIONAL std::decimal +std::math::var_pop(vals: SET OF std::decimal) -> OPTIONAL std::decimal { CREATE ANNOTATION std::description := 'Return the population variance of the input set.'; @@ -379,7 +379,7 @@ math::var_pop(vals: SET OF std::decimal) -> OPTIONAL std::decimal CREATE FUNCTION -math::var_pop(vals: SET OF std::int64) -> OPTIONAL std::float64 +std::math::var_pop(vals: SET OF std::int64) -> OPTIONAL std::float64 { CREATE ANNOTATION std::description := 'Return the population variance of the input set.'; @@ -393,7 +393,7 @@ math::var_pop(vals: SET OF std::int64) -> OPTIONAL std::float64 CREATE FUNCTION -math::var_pop(vals: SET OF std::float64) -> OPTIONAL std::float64 +std::math::var_pop(vals: SET OF std::float64) -> OPTIONAL std::float64 { CREATE ANNOTATION std::description := 'Return the population variance of the input set.'; diff --git a/edb/schema/schema.py b/edb/schema/schema.py index f8696c4f82b7..8f10249425c4 100644 --- a/edb/schema/schema.py +++ b/edb/schema/schema.py @@ -79,7 +79,7 @@ STD_MODULES = ( sn.UnqualName('std'), sn.UnqualName('schema'), - sn.UnqualName('math'), + sn.UnqualName('std::math'), sn.UnqualName('sys'), sn.UnqualName('cfg'), sn.UnqualName('cal'), diff --git a/edb/tools/experimental_interpreter/basis/server_funcs.py b/edb/tools/experimental_interpreter/basis/server_funcs.py index e4950e84dec6..48100f88f292 100644 --- a/edb/tools/experimental_interpreter/basis/server_funcs.py +++ b/edb/tools/experimental_interpreter/basis/server_funcs.py @@ -98,7 +98,7 @@ def default_impl(arg: Sequence[Sequence[e.Val]]) -> Sequence[e.Val]: return all_server_cal_funcs[name.names[1]] else: return default_impl - case "math": + case "std::math": if name.names[1] in all_server_math_funcs: return all_server_math_funcs[name.names[1]] else: diff --git a/tests/test_dump_v4.py b/tests/test_dump_v4.py index d404984a4802..638925596b75 100644 --- a/tests/test_dump_v4.py +++ b/tests/test_dump_v4.py @@ -44,7 +44,7 @@ async def _ensure_schema_data_integrity(self, include_secrets): r''' with x := range_unpack(range(1, 1000)) select all( - L2.vec in [x % 10, math::ln(x), x / 7 % 13] + L2.vec in [x % 10, std::math::ln(x), x / 7 % 13] ) ''', [ diff --git a/tests/test_dump_v5.py b/tests/test_dump_v5.py index bb89895b333b..8d56d1a11597 100644 --- a/tests/test_dump_v5.py +++ b/tests/test_dump_v5.py @@ -70,7 +70,7 @@ async def _ensure_data_integrity(self): r''' with x := range_unpack(range(1, 1000)) select all( - L2.vec in [x % 10, math::ln(x), x / 7 % 13] + L2.vec in [x % 10, std::math::ln(x), x / 7 % 13] ) ''', [ diff --git a/tests/test_edgeql_userddl.py b/tests/test_edgeql_userddl.py index 1c29b913f882..e8f62fcc5418 100644 --- a/tests/test_edgeql_userddl.py +++ b/tests/test_edgeql_userddl.py @@ -155,9 +155,9 @@ async def test_edgeql_userddl_09(self): async def test_edgeql_userddl_10(self): with self.assertRaisesRegex( edgedb.SchemaDefinitionError, - r'cannot create.*module math is read-only'): + r'cannot create.*module std is read-only'): await self.con.execute(''' - CREATE FUNCTION math::func_10( + CREATE FUNCTION std::math::func_10( a: str ) -> str USING EdgeQL $$ @@ -176,9 +176,9 @@ async def test_edgeql_userddl_11(self): async def test_edgeql_userddl_12(self): with self.assertRaisesRegex( edgedb.SchemaDefinitionError, - r'cannot create.*module math is read-only'): + r'cannot create.*module std is read-only'): await self.con.execute(''' - CREATE TYPE math::Foo_11; + CREATE TYPE std::math::Foo_11; ''') async def test_edgeql_userddl_13(self): @@ -210,9 +210,9 @@ async def test_edgeql_userddl_17(self): async def test_edgeql_userddl_18(self): with self.assertRaisesRegex( edgedb.SchemaDefinitionError, - r'cannot delete.*module math is read-only'): + r'cannot delete.*module std is read-only'): await self.con.execute(''' - DROP MODULE math; + DROP MODULE std::math; ''') async def test_edgeql_userddl_19(self): diff --git a/tests/test_schema.py b/tests/test_schema.py index ea2d8d657bd8..e34595b565a5 100644 --- a/tests/test_schema.py +++ b/tests/test_schema.py @@ -10235,7 +10235,7 @@ def test_schema_describe_09(self): abstract constraint my_constr1(val: int64) { using ( - WITH m AS MODULE math + WITH m AS MODULE std::math SELECT m::abs(__subject__ + val) > 2 ); }; @@ -10255,7 +10255,7 @@ def test_schema_describe_09(self): ''' abstract constraint test::my_constr0(val: std::int64) { using (SELECT - (math::abs((__subject__ + val)) > 2) + (std::math::abs((__subject__ + val)) > 2) ); }; ''', @@ -10266,7 +10266,7 @@ def test_schema_describe_09(self): abstract constraint test::my_constr1(val: std::int64) { using ( SELECT - (math::abs((__subject__ + val)) > 2) + (std::math::abs((__subject__ + val)) > 2) ); }; ''', @@ -10279,7 +10279,7 @@ def test_schema_describe_09(self): x := (__subject__ + val) SELECT - (math::abs(x) > 2) + (std::math::abs(x) > 2) ); }; ''',