Datasource Filtering Overview

This describes how filtering works in the Powerflex Provider with a datasource filter block

The input below will be used showcase different scenarios and how they will work in our provider:

[
  {
   id = "id-1"
   field = false
   count = 1
  },
  {
   id = "id-2"
   field = true
   count = 2
  },
  {
   id = "id-3"
   field = true
   count = 3
  }
]

1. If a single filter field is set, filter and only return those values

Config:

data "powerflex_example_datasource" "exampleFilter" {
  filter {
   id = ["id-1", "id-2"]
  }
}

Output:

[
  {
   id = "id-1"
   field = false
   count = 1
  },
  {
   id = "id-2"
   field = true
   count = 2
  }
]

2. If multiple filters are set then it is the intersection of those filters:

Config:

data "powerflex_example_datasource" "exampleFilter" {
  filter {
   id = ["id-1", "id-2"]
   count = [2]
  }
}

Output:

[
  {
   id = "id-2"
   field = true
   count = 2
  }
]

3. If there are no intersection then the output will be empty:

Config:

data "powerflex_example_datasource" "exampleFilter" {
  filter {
   id = ["id-1", "id-2"]
   count = [3]
  }
}

Output:

[]

4. If the filter value is invalid then the output will be empty:

Config:

data "powerflex_example_datasource" "exampleFilter" {
  filter {
   id = ["invaid-id"]
  }
}

Output:

[]