• Iustin Pop's avatar
    Implement Query2 filter JSON (de)serialisation · e8a25d62
    Iustin Pop authored
    This adds support for encoding/decoding Query2 filters to/from JSON,
    in (hopefully) the same format as the Python code generates.
    It also adds a simple unit-test to check that this conversion is
    idempotent. Of note here is that, since the Filter data type is
    recursive, we have to manually ensure that the generator for it
    correctly "shrinks" at each step (first version crashed hard my
    workstation after eating ~8GB of ram :).
    Compared to the current Query2 implementation, the following changes
    were done:
    - style: shortened some names to match the Python ones (LessEqualThan
      → LE, etc.)
    - changed FilterValue from string to an ADT that can encode both
      quoted strings and numeric values, since this is actually what
      qlang.py generates
    - added support for EmptyField, which in hindsight it's an obvious
      missing part :)
    Signed-off-by: default avatarIustin Pop <iustin@google.com>
    Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
QC.hs 76.9 KB