|
919 | 919 | :breakout (symbol "nil #_\"key is not present.\"") |
920 | 920 | :fields (symbol "nil #_\"key is not present.\"")}]} |
921 | 921 | second-result))))))) |
| 922 | + |
| 923 | +(deftest ^:parallel partial-dimensions-fill-from-row-test |
| 924 | + (testing "underlying-records drill fills in missing breakout-sourced row entries when the |
| 925 | + FE provides only some of the dimensions (#73803)" |
| 926 | + ;; Models a card where stage 1 has agg+breakouts (count by created-at:month, state); stage 2 |
| 927 | + ;; adds a filter `state = "AK"`. On the FE the scatter only puts CREATED_AT in graph.dimensions, |
| 928 | + ;; so the click context's :dimensions has just CREATED_AT — STATE is present in :row but, at |
| 929 | + ;; the last stage, its column metadata shows :source/previous-stage / :source :fields rather |
| 930 | + ;; than a breakout. The drill must still apply STATE = clicked-value to the underlying records. |
| 931 | + (let [base (-> (lib/query meta/metadata-provider (meta/table-metadata :people)) |
| 932 | + (lib/aggregate (lib/count)) |
| 933 | + (lib/breakout (-> (meta/field-metadata :people :created-at) |
| 934 | + (lib/with-temporal-bucket :month))) |
| 935 | + (lib/breakout (meta/field-metadata :people :state)) |
| 936 | + lib/append-stage) |
| 937 | + base-cols (lib/returned-columns base) |
| 938 | + created-at (lib.tu.notebook/find-col-with-spec |
| 939 | + base base-cols {} {:display-name "Created At: Month"}) |
| 940 | + state-col (lib.tu.notebook/find-col-with-spec |
| 941 | + base base-cols {} {:display-name "State"}) |
| 942 | + count-col (lib.tu.notebook/find-col-with-spec |
| 943 | + base base-cols {} {:display-name "Count"}) |
| 944 | + query (lib/filter base (lib/= state-col "AK")) |
| 945 | + context {:column count-col |
| 946 | + :column-ref (lib/ref count-col) |
| 947 | + :value 4 |
| 948 | + :row [{:column created-at |
| 949 | + :column-ref (lib/ref created-at) |
| 950 | + :value "2026-07-01T00:00:00Z"} |
| 951 | + {:column state-col |
| 952 | + :column-ref (lib/ref state-col) |
| 953 | + :value "AK"} |
| 954 | + {:column count-col |
| 955 | + :column-ref (lib/ref count-col) |
| 956 | + :value 4}] |
| 957 | + :dimensions [{:column created-at |
| 958 | + :column-ref (lib/ref created-at) |
| 959 | + :value "2026-07-01T00:00:00Z"}]} |
| 960 | + drill (m/find-first #(= (:type %) :drill-thru/underlying-records) |
| 961 | + (lib/available-drill-thrus query context)) |
| 962 | + _ (is (some? drill)) |
| 963 | + result (lib/drill-thru query drill)] |
| 964 | + (is (=? {:stages [{:source-table (meta/id :people) |
| 965 | + :filters [[:between {} |
| 966 | + [:field {:temporal-unit :month} (meta/id :people :created-at)] |
| 967 | + string? |
| 968 | + string?] |
| 969 | + [:= {} |
| 970 | + [:field {} (meta/id :people :state)] |
| 971 | + "AK"]] |
| 972 | + :aggregation (symbol "nil #_\"key is not present.\"") |
| 973 | + :breakout (symbol "nil #_\"key is not present.\"") |
| 974 | + :fields (symbol "nil #_\"key is not present.\"")}]} |
| 975 | + result))))) |
0 commit comments