Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A date field with date_nanos format can not be used as an index pattern time field. #40699

Closed
tsullivan opened this issue Jul 9, 2019 · 9 comments
Assignees
Labels
Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@tsullivan
Copy link
Member

Kibana version: 8.0.0/master

Elasticsearch version: 8.0.0/master

Steps to reproduce:

  1. Create an index that has a date_nanos field:

    PUT my_index?include_type_name=true
    {
      "mappings": {
        "_doc": {
          "properties": {
            "date": {
              "type": "date_nanos" 
    ...
    
    PUT my_index/_doc/1
    { "date": "2015-01-01" }
    
  2. Create an index pattern for the index

  3. date shows as a time field

  4. If you choose the date_nanos field as the time field, Discover will send erroneous queries to Elasticsearch.

image

Error message:

Request to Elasticsearch failed: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"date[1967-10-29T08:00:30Z] is before the epoch in 1970 and cannot be stored in nanosecond resolution"}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"my_index","node":"nMrM4ZZTSh68Xg5kWsl8iA","reason":{"type":"illegal_argument_exception","reason":"date[1967-10-29T08:00:30Z] is before the epoch in 1970 and cannot be stored in nanosecond resolution"}}],"caused_by":{"type":"illegal_argument_exception","reason":"date[1967-10-29T08:00:30Z] is before the epoch in 1970 and cannot be stored in nanosecond resolution","caused_by":{"type":"illegal_argument_exception","reason":"date[1967-10-29T08:00:30Z] is before the epoch in 1970 and cannot be stored in nanosecond resolution"}}},"status":400}
@tsullivan
Copy link
Member Author

Probably related to #37211

Looking at the code, it looks like the index pattern creation wizard should prevent the date_nanos field being used as the time field.

@tsullivan tsullivan added Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Jul 9, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app

@tsullivan
Copy link
Member Author

cc @kertal

@kertal kertal self-assigned this Jul 10, 2019
@kertal
Copy link
Member

kertal commented Jul 10, 2019

I've tried to reproduce the problem with you testdata without a problem. It's interesting that elasticsearch is retrieving a date of 1967. Since I don't think that you're currently time traveling, could you take a look which range query is sent to elasticsearch by kibana? Thx!

@tsullivan
Copy link
Member Author

Isolated to this part of the Discover query:

  "aggs": {
    "2": {
      "date_histogram": {
        "field": "date",
        "fixed_interval": "30d",
        "min_doc_count": 1,
        "time_zone": "America/Phoenix"
      }
    }
  },

@tsullivan
Copy link
Member Author

Simplest test case, without Discover:

DELETE /my_index

PUT my_index?include_type_name=true
{
  "mappings": {
    "_doc": {
      "properties": {
        "date": {
          "type": "date_nanos" 
        }
      }
    }
  }
}

PUT my_index/_doc/2
{ "date": "2019-07-15T00:00:00.123456789Z" } 


GET /my_index/_search
{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "date",
        "fixed_interval": "30d",
        "min_doc_count": 1,
        "time_zone": "America/Phoenix"
      }
    }
  }
}

@kertal
Copy link
Member

kertal commented Jul 16, 2019

I could reproduce it, and also make it work by removing the time_zone, or using another timezone

GET /my_index/_search
{
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "date",
        "fixed_interval": "30d",
        "min_doc_count": 1
      }
    }
  }
}

it's an Elasticsearch issue

@tsullivan
Copy link
Member Author

Possibly close this issue and follow: elastic/elasticsearch#39107

@timroes
Copy link
Contributor

timroes commented Jul 18, 2019

Closing this in favor of the upstream issue elastic/elasticsearch#39107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants