defradb icon indicating copy to clipboard operation
defradb copied to clipboard

Count aggregate errors on _group with parent filter

Open AndrewSisley opened this issue 6 months ago • 0 comments

Schema:

type PlayerAction {
  metadata: JSON
  deleted: Boolean
  action: Action @relation(name: "actionPlayerActions") // one-many
  player: Player @relation(name: "playerPlayerActions") // one-many
  playerRewards: [PlayerActionToPlayerReward] @relation(name: "playerActionPlayerRewards")
  createdAt: DateTime
}

Query:

query  {
  PlayerAction( 
    filter: { player_id: { _eq: "bae-d76c3c25-2558-512d-82e6-012abea5d0ee" } }
    groupBy: [action_id] 
  ) 
  {
    action_id
    _count(_group: {})
  }
}

Error (ln 439 of planner.go):

"unexpected type. Property: plan, Actual: *planner.multiScanNode"

We appear to have no tests for _count(_group: {}) with filters on the top level query (we have some with filters on the aggregate). Database was populated when the error was found, although the error suggests that that is irrelevant and I guess that this would be reproducible in an empty db.

Probably affects the other aggregates too.

Seems likely that this is a very old bug that will have been reproducible for a long time.

AndrewSisley avatar Aug 16 '24 20:08 AndrewSisley