Skip to content

Conversation

@Allison-E
Copy link
Contributor

I've begun implementing Cypher's temporal functions in AGE, beginning with date().

Here it is in action.

SELECT * FROM cypher('graph', $$
    RETURN date()
$$) as (today agtype);
    today     
--------------
 "2023-08-13"
(1 row)

It could also be converted to PostgreSQL's date type, but the record returned by AGE must first be converted to any of PostgreSQL's character types (char, varchar, or text).

SELECT TO_DATE(today, 'YYYY/MM/DD') FROM cypher('graph', $$
    RETURN date()
$$) as (today text);
--
-- or
--
SELECT today::date FROM cypher('graph', $$
    RETURN date()
$$) AS (today varchar(255));

Limitations

Although the date() function in Cypher accepts an optional zone parameter to specify what timezone to return, it isn't implemented here yet. Currently, the local time zone is returned. Hopefully, that will be implemented soon.

@rafsun42
Copy link
Member

@Allison-E

I did not find date function in the openCypher specification (your link refers to Neo4J doc, not openCypher).

Also, I was able to achieve the result using a PG function. Do you think we should add another implementaiton of date while we can use PG's?

(pg-15.4) agedev=# SELECT TO_DATE(today, 'YYYY/MM/DD') FROM cypher('graph', $$
    RETURN pg_catalog.now()
$$) as (today text);
  to_date   
------------
 2023-10-23
(1 row)

@rafsun42 rafsun42 self-assigned this Oct 23, 2023
@jrgemignani
Copy link
Contributor

jrgemignani commented Oct 24, 2023

@Allison-E You are not using the current master branch. The master is on 1.4.0, not 1.3.0.

image

@rafsun42 I think it is okay to include Neo4j functions as they created the openCypher documentation. Considering how vague and incomplete the openCypher specification can be, it is a good idea to look at Neo4j for clarifications.

@Allison-E
Copy link
Contributor Author

Hi @rafsun42, thanks for pointing out that pg_catalog.now() could be used in your comment. I think, however, that having the date() function alongside PostgreSQL's pg_catalog.now() would make for an easier adaptation for the people who move from Neo4j to Apache AGE. @jrgemignani's comment is also valid.

@jrgemignani, I'll rebase the code to the current master branch.

@rafsun42
Copy link
Member

@Allison-E The conflicts still exist. Also, there should not be any 'rebase' or 'merge' commit.

@Allison-E
Copy link
Contributor Author

@Allison-E The conflicts still exist. Also, there should not be any 'rebase' or 'merge' commit.

All done, @rafsun42.

@rafsun42
Copy link
Member

@Allison-E The date function does not work with the examples in this page.

@Allison-E
Copy link
Contributor Author

Allison-E commented Oct 31, 2023

@Allison-E The date function does not work with the examples in this page.

Sorry, I don't think I understand, @rafsun42. Could you please describe what you are trying to do that isn't working?

@rafsun42
Copy link
Member

@Allison-E

The following query does not work. The date function should be able to take a single argument as shown in the PG's doc.

SELECT * FROM cypher('graph', $$ RETURN date('1999-01-08') $$) as (a agtype);
ERROR:  function ag_catalog.age_date(agtype) does not exist
LINE 1: SELECT * FROM cypher('graph', $$ RETURN date('1999-01-08') $...
                                                    ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

@Allison-E
Copy link
Contributor Author

@rafsun42, I was hoping to work on that soon.

@github-actions
Copy link

This PR is stale because it has been open 45 days with no activity. Remove "Abondoned" label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale Stale issues/PRs label May 11, 2024
@github-actions
Copy link

This PR was closed because it has been stalled for further 7 days with no activity

@github-actions github-actions bot closed this May 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master Stale Stale issues/PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants