Datetime range selection problem

Moved from GitHub dgraph/5630

Posted by mikehawkes:

What version of Dgraph are you using?

20.03.3

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

Docker image running on Mac Pro (32GiB RAM; 18 Core; MacOS 10.14.6)

Steps to reproduce the issue (command/config used to run Dgraph).

Run the following query:

data (func:ge(hours.tracked, 2020-01-01)) @filter(le(hours.tracked, 2020-01-31)) {
hours.tracked
}

Expected behaviour and actual result.

Expected:

{
  "data": {
    "data": [
      {
        "hours.tracked": "2020-01-27T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-30T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-27T00:00:00Z"
      },
...

Instead, I get nothing back.

{
  "data": {
    "data": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 176200,
      "processing_ns": 124909100,
      "encoding_ns": 20300,
      "assign_timestamp_ns": 6015700,
      "total_ns": 131698500
    },
    "txn": {
      "start_ts": 2215408
    },
    "metrics": {
      "num_uids": {
        "hours.tracked": 0
      }
    }
  }
}

Yet, if I run the query (against the same data) as:

query {
  var  (func:ge(hours.tracked, 2020-01-01)) {
    u as uid
  }
	data(func:le(hours.tracked,2020-01-31)) @filter(uid(u)) {
    hours.tracked
  }
}

I get the expected result.

OmarAyo commented :

Hi @mikehawkes,

I was able to run the first query you posted and I got the expected results:

{
data (func:ge(hours.tracked, 2020-01-01)) @filter(le(hours.tracked, 2020-01-31)) {
hours.tracked
}
}

gives the following result:

{
  "data": {
    "data": [
      {
        "hours.tracked": "2020-01-29T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-30T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-27T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-28T00:00:00Z"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 110139,
      "processing_ns": 8237287,
      "encoding_ns": 33593,
      "assign_timestamp_ns": 501193,
      "total_ns": 8964009
    },
    "txn": {
      "start_ts": 56
    },
    "metrics": {
      "num_uids": {
        "_total": 8,
        "hours.tracked": 8
      }
    }
  }
}

Are you indexing hours.tracked ? Can you share you dataset so we can try to see if we can reproduce

Thanks

mikehawkes commented :

I shared the schema - yes, it’s indexed - and I have tried changing the index type to day and hour, just in case it was the index type. This one’s weird because it seems intermittent - sometimes it works, sometimes it goes astray. I’ve also exported then re-imported the data (clearing down in between), just in case. Also tried doing a complete delete, including zapping the docker containers and fetching the latest, just in case. Then imported the RDF dump - it worked, then stopped working a few minutes later.

I’m happy to share the data if it’s treated in confidence (I can’t share it in a public forum, however).

It’s doing it again … returns no data if using both ge and le to define a date range.

For anyone else suffering this - the following works:

var(func:ge(hours.tracked,"2020-07-01")) {
    hl as uid
}

var(func:le(hours.tracked("2020-07-31")) @filter(uid(hl)) {
...
}

Do you have multiple alphas or only a single instance?

This in standalone. I switched to see if it was a sync issue.