If you wanted something like this in Postgres, then good news is that PG19 (currently in beta) is adding SQL/PGQ support as well.