Bug in date filtering

Hi

Date filtering doesn’t work as expected:

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

Returns:

{
  "data": {
    "data": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 204300,
      "processing_ns": 67503500,
      "encoding_ns": 15100,
      "assign_timestamp_ns": 2431000,
      "total_ns": 70636000
    },
    "txn": {
      "start_ts": 2190872
    },
    "metrics": {
      "num_uids": {
        "hours.tracked": 0
      }
    }
  }
}

Whereas:

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
  }
}

Returns the expected results …

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

Hey @mikehawkes ,

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

is working fine for me and returning the following result,

{
  "data": {
    "data": [
      {
        "hours.tracked": "2020-01-31T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-21T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-20T00:00:00Z"
      }
  ]
}

Can you please share your schema?

Sure - can I send this via email? It’s a real project.

For information, it worked fine - then I got weird results, so traced it to the query returning nothing. I exported, deleted the whole lot, grabbed the latest docker image and re-imported. It worked, then a few minutes later stopped again. It’s a weird one!

While I have a workaround, I have a few other odd bugs around dates and I wonder if the date indexes have an issue. I also tried deleting the index, and adding it again. And tried changing from Day to Hour (with a change to include time in the query), all with the same result.

It would be better if you can post it here, others also will be able to help you out. You can email me otherwise.

Ok …

<employee.firstname>: string @index(fulltext) .
<employee.group>: uid @reverse .
<employee.id>: string @index(exact) .
<employee.lastname>: string .
<employee.location>: string .
<employee.xeroContactID>: string .
<employee>: [uid] .
<group.id>: string @index(exact) .
<group.member>: [uid] @reverse .
<group.name>: string .
<hours.annul>: bool .
<hours.annulText>: string .
<hours.bill>: bool .
<hours.billText>: string .
<hours.comment>: string .
<hours.created>: datetime @index(hour) .
<hours.hold>: bool .
<hours.holdText>: string .
<hours.hours>: float .
<hours.id>: string @index(exact) .
<hours.query>: bool .
<hours.queryText>: string .
<hours.status>: string @index(exact) .
<hours.tracked>: datetime @index(day) .
<hours.updated>: datetime @index(hour) .
<hours>: [uid] @reverse .
<invoice.PONumber>: string .
<invoice.accountCode>: string .
<invoice.accountNumber>: string .
<invoice.billingType>: string .
<invoice.currency>: string .
<invoice.date>: datetime @index(day) .
<invoice.hours>: [uid] .
<invoice.lineItems>: [uid] .
<invoice.office>: string .
<invoice.projectName>: string @index(exact) .
<invoice.type>: string @index(exact) .
<invoice.xeroContact>: string .
<lineitem.description>: string .
<lineitem.quantity>: float .
<lineitem.taxCode>: string .
<lineitem.unitPrice>: float .
<office.name>: string @index(exact) .
<office>: uid @reverse .
<project.PONumber>: string .
<project.billable>: string .
<project.billingType>: string @index(exact) .
<project.currency>: string .
<project.deferred>: string .
<project.description>: string .
<project.endDate>: datetime .
<project.estimatedBudget>: float .
<project.estimatedTime>: string .
<project.expenses>: string .
<project.financialStatus>: string @index(exact) .
<project.gluid>: string .
<project.id>: string @index(exact) .
<project.office>: string .
<project.rate>: float .
<project.seniorConsultant>: string .
<project.startDate>: datetime @index(day) .
<project.status>: string .
<project.statusText>: string .
<project.technology>: string .
<project.title>: string @index(term) .
<project.triangle>: string .
<project.xeroAccountCode>: string .
<projectManager>: uid @reverse .
<system.lastruntime>: datetime .
<task.billable>: string .
<task.id>: string @index(exact) .
<task.rate>: float .
<task.title>: string .
<task>: [uid] @reverse .
<technology.name>: string @index(exact) .
<technology>: uid .
<triangle.name>: string @index(exact) .
<triangle>: uid @reverse .

# Types
type Project {
	project.PONumber
	project.billable
	project.billingType
	project.currency
	project.deferred
	project.description
	project.endDate
	project.estimatedBudget
	project.estimatedTime
	project.expenses
	project.financialStatus
	project.gluid
	project.id
	project.office
	project.rate
	project.seniorConsultant
	project.startDate
	project.status
	project.statusText
	project.technology
	project.title
	project.triangle
	project.xeroAccountCode
	projectManager
	triangle
	technology
	office
	employee
	task
}

type Task {
	task.billable
	task.id
	task.rate
	task.title
	hours
	employee
}

type Employee {
	employee.firstname
	employee.group
	employee.id
	employee.lastname
	employee.location
	employee.xeroContactID
	hours
}

type Hours {
	hours.annul
	hours.annulText
	hours.bill
	hours.billText
	hours.comment
	hours.created
	hours.hold
	hours.holdText
	hours.hours
	hours.id
	hours.query
	hours.queryText
	hours.status
	hours.tracked
	hours.updated
	employee
}

type Group {
	group.id
	group.member
	group.name
}

type Invoice {
	invoice.PONumber
	invoice.accountCode
	invoice.accountNumber
	invoice.billingType
	invoice.currency
	invoice.date
	invoice.hours
	invoice.lineItems
	invoice.office
	invoice.projectName
	invoice.type
	invoice.xeroContact
}

type Lineitem {
	lineitem.description
	lineitem.quantity
	lineitem.taxCode
	lineitem.unitPrice
}

type Office {
	office.name
}

type System {
	system.lastruntime
}

type Technology {
	technology.name
}

type Triangle {
	triangle.name
}

I am not sure what is causing the issue here. It looks like a bug to me, can you please file it on our github and we’ll start working on it. Also can you please share the information about the other issues that you’re facing with datetime indexes?
Follow this post for more details on datetime indexes.

Done. It looks like I’m getting intermittent data returns from datetime. I’m still having to look in detail, and will come back when I’ve confirmed it. On first pass, it looks like it falls apart if I do a combined le/ge filter or selection. If I break out the first selection into a var then do a filter via uid, then things seem to work.

It’s weird in that it initially works, then stops for some reason.

Thanks a lot for reporting the issue :smiley:. Feel free to ask any other doubts you have or add more information related to this issue.