I don't remember why I had made it a macro, but it needs to be a function so it can be called correctly in org-ql--query.