# Transforms failed status with runtime fields

**URL:** https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444
**Category:** Kibana
**Tags:** transforms, runtime-fields
**Created:** [April 27, 2022, 9:22pm UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444 "2022-04-27T21:22:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ann\_Abbott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ann_abbott/32/98018_2.png) [@Ann\_Abbott](https://discuss.elastic.co/u/Ann_Abbott)
#### Post date: [April 27, 2022, 9:22pm UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444/1 "2022-04-27T21:22:38Z")

</div>

Hi,  
I am trying to create a transforms index with runtime-fields called adoption\_time\_stamp that's in a date format.

 ![Screen Shot 2022-04-27 at 2.17.12 PM](https://us1.discourse-cdn.com/elastic/original/3X/8/f/8ff53fff382daa77ceff0a8332759aa82e4ed7fb.png)

Every time I try to create a transforms index with this adoption\_time\_stamp runtime\_field, I get this error saying it has failed to parse the date field of [-9223372036854775808]. This epoch does not exist in my adoption\_time\_stamp and am confused how to fix this error.

 ![Screen Shot 2022-04-27 at 2.14.51 PM](https://us1.discourse-cdn.com/elastic/original/3X/2/4/2445069aca965119565886b7643d13b355754523.png)

---

<div class="post-metadata">

### Author: ![przemekwitek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/przemekwitek/32/79526_2.png) [@przemekwitek](https://discuss.elastic.co/u/przemekwitek)
#### Post date: [April 28, 2022, 8:00am UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444/2 "2022-04-28T08:00:53Z")

</div>

Hi,  
Welcome to the Elastic discuss channel!

The number `-9223372036854775808` is just the minimum number an integer type can hold. So it may be that there are some missing values of the `adoption_time_stamp` field that get translated to the minimum integer value.

A few questions:

1. How do you configure the `adoption_time_stamp` runtime field? Is it in the index mapping for all of the indices matching `events-*` pattern?

You can find out by calling:

```auto
GET events-*/_mapping

```

1. How are you using this `adoption_time_stamp` field in transform?  
Is it configured as a `sync` field?  
Is the transform continuous?  
Does the transform itself specify runtime fields?

Would be good if you posted the transform config here.  
You can obtain it by calling:

```auto
GET _transform/max_adoption

```

---

<div class="post-metadata">

### Author: ![Ann\_Abbott](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ann_abbott/32/98018_2.png) [@Ann\_Abbott](https://discuss.elastic.co/u/Ann_Abbott)
#### Post date: [April 29, 2022, 7:16pm UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444/3 "2022-04-29T19:16:16Z")

</div>

I am trying to use adoption\_time\_stamp as a main @timestamp in transform.  
Not sure if it's configured as a sync field but the transform is continuous.  
This is the result when I call

```auto
GET _transform/max_adoption

```

```auto
{
  "count" : 1,
  "transforms" : [
    {
      "id" : "max_adoption",
      "version" : "8.1.1",
      "create_time" : 1650863362505,
      "source" : {
        "index" : [
          "events-*"
        ],
        "query" : {
          "match_all" : { }
        },
        "runtime_mappings" : {
          "order_item_fill_count" : {
            "type" : "double",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /ORDER_CREATED/ && doc['order_item.type'].value ==~ /FILL/)
{
emit(1);
}
else if (doc['event_ctx.event_type'].value ==~ /ORDER_ITEM_STATUS_CHANGED/ && doc['order_item.type'].value ==~ /FILL/)
{
emit(-1)
}
else
{
emit(0)
}"""
            }
          },
          "ordered_fill_count_with_cancellation" : {
            "type" : "double",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /ORDER_CREATED/ && doc['order_item.type'].value ==~ /FILL/)
{
emit(1);
}
else
{
emit(0)
}"""
            }
          },
          "pharmacy_sold_fill_count" : {
            "type" : "double",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /RX_FILL_STATE_CHANGED/) 
{ 
    if (doc.containsKey('data_tags.FILL_EVENT_TYPE.keyword') && 
    doc['data_tags.FILL_EVENT_TYPE.keyword'].size() > 0)
    {
        if (doc['data_tags.FILL_EVENT_TYPE.keyword'].value ==~ /FILL_SOLD_BY_PHARMACY/)
        {
        emit(1)
        }
        else 
        {
        emit(0)   
        }
    }
    else 
    {
    emit(0)
    }
}
else
{
emit(0)
}"""
            }
          },
          "adoption_time_stamp" : {
            "type" : "date",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /RX_FILL_STATE_CHANGED/) 
{ 
    if (doc.containsKey('data_tags.FILL_EVENT_TYPE.keyword') && 
    doc['data_tags.FILL_EVENT_TYPE.keyword'].size() > 0)
    {
        if (doc['data_tags.FILL_EVENT_TYPE.keyword'].value ==~ /FILL_SOLD_BY_PHARMACY/)
        {
        emit(doc['event_ctx.timestamp'].value.millis)
        }
    }
}
else if (doc['event_ctx.event_type'].value ==~ /ORDER_CREATED/ && doc['order_item.type'].value ==~ /FILL/)
{
emit(doc['event_ctx.timestamp'].value.millis);
}"""
            }
          },
          "order_counting" : {
            "type" : "double",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /ORDER_CREATED/)
{
emit(1);
}
else if (doc['event_ctx.event_type'].value ==~ /ORDER_ITEM_STATUS_CHANGED/)
{
emit(-1)
}
else
{
emit(0)
}"""
            }
          },
          "count_package" : {
            "type" : "double",
            "script" : {
              "source" : """if (doc['event_ctx.event_type'].value ==~ /PACKAGE_CREATED_FOR_ORDER/)
{
emit(1)
}
else if (doc['event_ctx.event_type'].value ==~ /PACKAGE_STATUS_CHANGED/) 
{ 
    if (doc.containsKey('package.delivery_status.keyword') && 
    doc['package.delivery_status.keyword'].size() > 0)
    {
        if (doc['package.delivery_status.keyword'].value ==~ /C/)
        {
        emit(-1)
        }
        else 
        {
        emit(0)   
        }
    }
}
else
{
emit(0)
}"""
            }
          }
        }
      },
      "dest" : {
        "index" : "max_adoption"
      },
      "frequency" : "1m",
      "sync" : {
        "time" : {
          "field" : "@timestamp",
          "delay" : "60s"
        }
      },
      "pivot" : {
        "group_by" : {
          "pharmacy.name" : {
            "terms" : {
              "field" : "pharmacy.name"
            }
          },
          "adoption_time_stamp" : {
            "date_histogram" : {
              "field" : "adoption_time_stamp",
              "calendar_interval" : "1d"
            }
          },
          "pharmacy.launch_date" : {
            "date_histogram" : {
              "field" : "pharmacy.launch_date",
              "calendar_interval" : "1d"
            }
          }
        },
        "aggregations" : {
          "ordered_fill_count_with_cancellation.sum" : {
            "sum" : {
              "field" : "ordered_fill_count_with_cancellation"
            }
          },
          "pharmacy_sold_fill_count.sum" : {
            "sum" : {
              "field" : "pharmacy_sold_fill_count"
            }
          }
        }
      },
      "settings" : {
        "max_page_search_size" : 500
      }
    }
  ]
}

```

---

<div class="post-metadata">

### Author: ![przemekwitek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/przemekwitek/32/79526_2.png) [@przemekwitek](https://discuss.elastic.co/u/przemekwitek)
#### Post date: [May 4, 2022, 10:48am UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444/4 "2022-05-04T10:48:12Z")

</div>

Thanks for the config.  
`adoption_time_stamp` is used in the group-by section but it is **not** the `sync.time` field. Maybe that's ok for your use-case, but please double-check.

What is more worrying, the function (script) calculating `adoption_time_stamp` is not complete, i.e. it doesn't emit a value in certain conditions:

```auto
    if (doc.containsKey('data_tags.FILL_EVENT_TYPE.keyword') && 
    doc['data_tags.FILL_EVENT_TYPE.keyword'].size() > 0)
    {
        if (doc['data_tags.FILL_EVENT_TYPE.keyword'].value ==~ /FILL_SOLD_BY_PHARMACY/)
        {
        emit(doc['event_ctx.timestamp'].value.millis)
        }
    }

```

What I mean is, when `if (doc['data_tags.FILL_EVENT_TYPE.keyword'].value ==~ /FILL_SOLD_BY_PHARMACY/)` evaluates to `true`, a value is emitted, but if, on the other hand, it evaluates to `false`, nothing is emitted and this can manifest itself with the error message you are getting. Please add some `else` branch and re-check the transform.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 1, 2022, 10:48am UTC](https://discuss.elastic.co/t/transforms-failed-status-with-runtime-fields/303444/5 "2022-06-01T10:48:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
