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

DATETIME is not supported in Cast() #268

Closed
davidcui1225 opened this issue Nov 1, 2019 · 0 comments
Closed

DATETIME is not supported in Cast() #268

davidcui1225 opened this issue Nov 1, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@davidcui1225
Copy link
Contributor

Extension of #225

Queries that cast a field to type DATETIME return errors.

Example query:

SELECT CAST(timestamp AS DATETIME) FROM kibana_sample_data_flights LIMIT 10

Returns:

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)",
          "java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)",
          "java.base/java.lang.Double.parseDouble(Double.java:549)",
          "cast_field1 = new Date(Double.parseDouble(doc['timestamp'].value.toString()).longValue()); ",
          "                                                                ^---- HERE"
        ],
        "script": "def cast_field1 = new Date(Double.parseDouble(doc['timestamp'].value.toString()).longValue()); return cast_field1",
        "lang": "painless"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "kibana_sample_data_flights",
        "node": "3ZdEGtaiRt2uUzeNPRmNZQ",
        "reason": {
          "type": "script_exception",
          "reason": "runtime error",
          "script_stack": [
            "java.base/jdk.internal.math.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2054)",
            "java.base/jdk.internal.math.FloatingDecimal.parseDouble(FloatingDecimal.java:110)",
            "java.base/java.lang.Double.parseDouble(Double.java:549)",
            "cast_field1 = new Date(Double.parseDouble(doc['timestamp'].value.toString()).longValue()); ",
            "                                                                ^---- HERE"
          ],
          "script": "def cast_field1 = new Date(Double.parseDouble(doc['timestamp'].value.toString()).longValue()); return cast_field1",
          "lang": "painless",
          "caused_by": {
            "type": "number_format_exception",
            "reason": "For input string: \"2019-07-22T00:00:00.000Z\""
          }
        }
      }
    ]
  },
  "status": 400
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants