Skip to content

SQL Plugin returns double instead of date type for functions NOW() and CURDATE() [BUG] #260

Closed

Description

Describe the bug
Calling NOW() and CURDATE() returns NULL for the JDBC driver while calling NOW() and CURDATE() on the SQL Plugin returns the expected results

To Reproduce
Steps to reproduce the behavior:

  1. Load the calcs table on to the server
  2. Run a query with NOW() or CURDATE() to the SQL Plugin for example curl -XPOST http://localhost:9200/_plugins/_sql -u admin:admin --insecure -H 'Content-Type: application/json' -d '{"query": "SELECT CURDATE() FROM calcs LIMIT 1"}' for Windows Subsystem for Linux

Expected behavior
The output should be of some date type like date or datetime

Actual behavior
The output is of type double.

Screenshot
image

Host/Environment (please complete the following information):

  • OS: Windows 10
  • Version 21H1

Activity

  1. ghost added on Nov 2, 2021
  2. ghost added
    bug
    on Nov 2, 2021
  3. ghost changed the title [-]JDBC driver returns null for functions NOW() and CURDATE() [BUG][/-] [+]SQL Plugin returns double instead of date type for functions NOW() and CURDATE() [BUG][/+] on Nov 2, 2021
  4. Yury-Fridlyand commented on Nov 3, 2021

    @Yury-Fridlyand
    Collaborator

    See also #259. Perhaps this bug could be fixed in scope of #259.

  5. chloe-zh commented on Nov 13, 2021

    @chloe-zh
    Contributor

    The new engine has not supported these functions, looks like the functions are executed in old engine. Should add such support in new query engine to address this issue

  6. added and removed
    bug
    on Nov 13, 2021
  7. chloe-zh commented on Nov 13, 2021

    @chloe-zh
    Contributor

    related issue: #48

  8. added
    tdvt
    on Nov 24, 2021
  9. dai-chen commented on Dec 14, 2022

    @dai-chen
    Collaborator

    I think this is already fixed along with the new impl in v2 engine. Tested in OpenSearch playground as below:

    POST _plugins/_sql
    {
     "query": "select now(), curdate()"
    }
    
    {
     "schema": [
       {
         "name": "now()",
         "type": "datetime"
       },
       {
         "name": "curdate()",
         "type": "date"
       }
     ],
     "datarows": [
       [
         "2022-12-14 03:27:48",
         "2022-12-14"
       ]
     ],
     "total": 1,
     "size": 1,
     "status": 200
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    new-engine-gaptdvt

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions