rjurney
08/28/2025, 7:09 AMflatten operator is missing šVaibhav (BAML š)
08/28/2025, 7:19 AMrjurney
08/28/2025, 6:38 PMrjurney
08/30/2025, 2:20 AMrjurney
08/30/2025, 2:22 AMbaml-sam
08/30/2025, 6:16 PMrjurney
08/30/2025, 9:43 PMbaml-sam
08/30/2025, 11:40 PM_.role and ctx.output_format - but we're also working on a whole bunch of other things that will enable us to eventually provide a more powerful standard library, and get rid of things like jinja filtersbaml-sam
08/30/2025, 11:41 PMflatten. Thanks for the context!rjurney
08/31/2025, 8:10 AMCompanyList as input and a CompanyList as output in a MatchingResult where I do multiple record match + merges. I need to validate the result in the exported Pydantic object by checking that all entity IDs in the output `CompanyLists`'s Company.source_ids field came from the input `CompanyList`'s Company.id fields. There seems no other way to do this without that operator...rjurney
08/31/2025, 8:10 AMrjurney
08/31/2025, 8:12 AMbaml-sam
08/31/2025, 7:53 PMflatten would have helped with this, but this feels like a thing we need to improve @assert forbaml-sam
08/31/2025, 7:54 PMinput args to an assertionbaml-sam
08/31/2025, 7:57 PMrjurney
08/31/2025, 8:02 PMrjurney
08/31/2025, 8:02 PMrjurney
08/31/2025, 8:03 PMrjurney
09/05/2025, 12:12 AMflatten would help here:
@@assert(referential_integrity, {{
this.relationships is not none and
this.relationships|map(attribute='src_company')|
select('in', this.companies|map(attribute='id'))|list|length ==
this.relationships|length and
this.relationships|map(attribute='dst_company')|
select('in', this.companies|map(attribute='id'))|list|length ==
this.relationships|length
}})rjurney
09/05/2025, 12:13 AMflatten but maybe it can if I keep at it. Or aghast⦠I could write it šbaml-sam
09/05/2025, 9:21 PM{{
relationships is not none and
relationships|rejectattr('src_company', 'in', companies|map(attribute='id'))|list|length == 0 and
relationships|rejectattr('dst_company', 'in', companies|map(attribute='id'))|list|length == 0
}}
Which I think works? Here's what I was testing with in [minijinja](https://mitsuhiko.github.io/minijinja-playground/):
{%- set relationships = [
{"src_company": 1, "dst_company": 2},
{"src_company": 2, "dst_company": 3},
{"src_company": 1, "dst_company": 3}
] -%}
{%- set companies = [
{"id": 1},
{"id": 2},
{"id": 3}
] -%}
Every src_company and dst_company exists in companies: {{
relationships is not none and
relationships|map(attribute='src_company')|
select('in', companies|map(attribute='id'))|list|length ==
relationships|length and
relationships|map(attribute='dst_company')|
select('in', companies|map(attribute='id'))|list|length ==
relationships|length
}}
using rejectattr: {{
relationships is not none and
relationships|rejectattr('src_company', 'in', companies|map(attribute='id'))|list|length == 0 and
relationships|rejectattr('dst_company', 'in', companies|map(attribute='id'))|list|length == 0
}}baml-sam
09/05/2025, 9:22 PMrjurney
09/09/2025, 12:24 AM