#2860·yq

asymmetry between map_values and map (inconsistent with jq)

Author: dhx-mike-palandraCreated Sep 11, 2026Updated Sep 14, 2026
Labelsbugv4

Same expression behaves differently between yq and jq:

$ yq -ojson -n '{"a": null, "b": "x"} | map_values(select(. != null))'
{
  "a": null,
  "b": "x"
}
$ jq -n '{"a": null, "b": "x"} | map_values(select(. != null))'
{
  "b": "x"
}

Even if you're not aiming for jq compatibility, it's inconsistent with map:

$ yq -ojson -n '{"a": null, "b": "x"} | map(select(. != null))'
[
  "x"
]

IMHO, jq handles this correctly.

Version of yq:

$ yq --version
yq (https://github.com/mikefarah/yq/) version v4.53.6

Operating system: Linux Installed via: GitHub release