发布

  • [OPIK-5431] [BE] Fix IS_EMPTY/IS_NOT_EMPTY filters for DICTIONARY field type (#6042)

    frostbyte_neo 发布于 2026-04-02 08:39:00 +00:00

    • [OPIK-5431] [BE] Fix IS_EMPTY/IS_NOT_EMPTY filters for DICTIONARY field type

    Filtering experiments (or any entity) by a metadata/dictionary field using
    the IS_EMPTY or IS_NOT_EMPTY operators was returning HTTP 400 because:

    1. FilterQueryBuilder had no SQL templates for those operator+type combos.
    2. FiltersFactory validation rejected the filter when value was null/empty
      for DICTIONARY/DICTIONARY_STATE_DB types.
    3. FiltersFactory tried to URL-decode a null value, causing a NullPointerException.

    Fix:

    • Add JSON_EXISTS-based SQL templates to FilterQueryBuilder for both operators
      on DICTIONARY and DICTIONARY_STATE_DB:
      IS_EMPTY → JSON_EXISTS(col, :filterKey) = false
      IS_NOT_EMPTY → JSON_EXISTS(col, :filterKey) = true
      This correctly distinguishes "key not present" from "key present but empty".
    • Update FIELD_TYPE_VALIDATION_MAP in FiltersFactory to accept IS_EMPTY /
      IS_NOT_EMPTY with only a key (no value required).
    • Guard the URL-decode step in toValidAndDecoded() to skip NO_VALUE_OPERATORS,
      preventing NPE when filter.value() is null.

    Add integration tests in ExperimentsResourceFindProjectExperimentsTest:

    • IS_NOT_EMPTY on $.config.name returns the experiment that has the key.
    • IS_EMPTY on $.config.name returns the experiment whose metadata is null
      (key not present at all).

    Implements OPIK-5431: [BE] Grouping experiments by configuration doesn't show
    results for Undefined group

    • [OPIK-5431] [BE] Fix IS_EMPTY/IS_NOT_EMPTY for DICTIONARY fields to handle null and empty values
    • IS_EMPTY now matches: key absent, empty string value, or JSON null value
    • IS_NOT_EMPTY now requires: key present with a non-empty, non-null value
    • JSON_VALUE returns the string 'null' for JSON null in ClickHouse (not SQL NULL),
      so the condition checks for both '' and 'null' explicitly
    • Updated findByFilterMetadataEmpty test to use assertExperiments
    • Added findByFilterMetadataEmptyWithNullAndBlankValues test covering the
      key-with-null-value and key-with-empty-string-value cases
    下载附件