Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Year(MyDateField) <= YEAR(NOW()) not supported #1073

Open
FreCap opened this issue Mar 15, 2021 · 4 comments
Open

Year(MyDateField) <= YEAR(NOW()) not supported #1073

FreCap opened this issue Mar 15, 2021 · 4 comments
Labels
enhancement New feature or request SQL

Comments

@FreCap
Copy link
Contributor

FreCap commented Mar 15, 2021

Is there any way to get the current year?

YEAR(NOW()) 

seems currently not supported

{
  "error": {
    "reason": "There was internal problem at backend",
    "details": "Nested function calls like [YEAR(NOW())] are not supported yet",
    "type": "SqlFeatureNotImplementedException"
  },
  "status": 503
}

Version: Version 1.13.0.0

@dai-chen
Copy link
Member

Thanks for reporting the issue! Investigating. Are you using the latest ODFE version?

@FreCap
Copy link
Contributor Author

FreCap commented Mar 15, 2021

Yes, latest version

@dai-chen
Copy link
Member

dai-chen commented Mar 15, 2021

It seems function NOW() is missing in new engine. It is supported by old engine by fallback but unfortunately nested function call and SELECT without FROM are not. Need to add it to the new engine: https://github.com/opendistro-for-elasticsearch/sql/blob/develop/docs/user/dql/functions.rst#now

@dai-chen
Copy link
Member

Reference to MySQL and PostgreSQL spec:

  1. MySQL's NOW(): "returns a constant time that indicates the time at which the statement began to execute ... The value is expressed in the session time zone ..."
  2. PostgreSQL's NOW(): "returns the start time of the current statement (more specifically, the time of receipt of the latest command message from the client) ... deliver values with time zone ..."

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request SQL
Projects
None yet
Development

No branches or pull requests

2 participants