jrgemignani commented on PR #807:
URL: https://github.com/apache/age/pull/807#issuecomment-1507741698

   @rrrokhtar 
   
   > It is mentioned in the project that I am assigned to, so that creating it 
is not my suggestion at all but it is may be good to be added...
   
   One of the jobs of an SE is questioning whether something is wise to do, or 
not. But, let's suppose it is and go on to your next statement.
   
   > ...added because you can not use pg_catalog.factorial function inside the 
cypher query
   
   Technically, you can, although it is cumbersome -
   
   ```
   psql-11.5-5432-pgsql=# SELECT * from cypher('graph1', $$ RETURN 
pg_catalog.factorial(25::pg_bigint) $$) as (result numeric);
              result
   ----------------------------
    15511210043330985984000000
   (1 row)
   
   psql-11.5-5432-pgsql=#
   ```
   
   > The variable types are following PostgreSQL and the similar mathematical 
functions on the same file like ag_sqrt.
   
   But sqrt follows the **cypher specification** that states sqrt outputs a 
float. There is no such specification for factorial as Neo4j doesn't have it. 
You need to be careful just copying another function without checking, or 
thinking about, how your functions' output should be represented and how the 
copied function works. Additionally, your function causes a loss of precision 
due to your variable usage.
   
   > There is no regression are added to the mathematical functions at all 
(i.e. age_sqrt) so I didn't write for it as well...
   
   Except that there are regression tests for all (unless we missed a few) 
supported mathematical functions. Here is sqrt's - 
   
   ```
   --
   -- sqrt()
   --
   SELECT * from cypher('expr', $$
       RETURN sqrt(25)
   $$) as (result agtype);
   SELECT * from cypher('expr', $$
       RETURN sqrt(1)
   $$) as (result agtype);
   SELECT * from cypher('expr', $$
       RETURN sqrt(0)
   $$) as (result agtype);
   ```
   
   I was purposely vague in not pointing out where a lot of this stuff is 
because I feel that it would be good for you to look around and get better 
acquainted with AGE and the AGE repository before proceeding. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to