Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom columns not appearing in result set when selecting subset of fields #20229

Closed
dpsutton opened this issue Feb 3, 2022 · 2 comments · Fixed by #20239
Closed

Custom columns not appearing in result set when selecting subset of fields #20229

dpsutton opened this issue Feb 3, 2022 · 2 comments · Fixed by #20239
Assignees
Labels
.Frontend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects

Comments

@dpsutton
Copy link
Contributor

dpsutton commented Feb 3, 2022

Create a question on the sample dataset on Orders, and create a custom column called "adjective" who's formula is case([Total] > 100, "expensive", "cheap")

The custom column appears in the results when all fields on Orders are selected, but does not appear when only a subset of fields are selected:

NOTE: most important is release-x.42.x It is possible this bug does not manifest in master. Will need a e2e test when we have narrowed and identified.

image
image
image
image

@dpsutton dpsutton added Type:Bug Product defects .Needs Triage labels Feb 3, 2022
@dpsutton
Copy link
Contributor Author

dpsutton commented Feb 3, 2022

I think this is a FE bug. The query when selecting all fields is:

;; selecting all fields omits a fields entry
{:database 1
 :query {:source-table 2
         :expressions {:adjective ["case"
                                   [[[">"
                                      ["field" 7 nil]
                                      100]
                                     "expensive"]]
                                   {:default "cheap"}]}}
 :type "query"
 :parameters []}

Since there are no fields, the fields it computes all of the fields involved in the query. However, the query sent over from the FE when you select only a subset of fields:

;; selecting a subset includes only the fields from the orders table and not the custom expression
{:database 1
 :query {:source-table 2
         :expressions {:adjective ["case"
                                   [[[">"
                                      ["field" 7 nil]
                                      100]
                                     "expensive"]]
                                   {:default "cheap"}]}
         :fields [["field" 9 nil]
                  ["field" 7 nil]
                  ["field" 4 nil]]}
 :type "query"
 :parameters []}

Note the lack of the custom column in the fields to select. As far as I can tell the backend is behaving correctly and not returning the custom column.

the correct query that should be sent from the FE is the following query. Note there is no possible way for the backend to anticipate which fields should be selected once you send a subset of them. You must include all fields you want to select.

;; the correct query when you add the custom column to the query after selecting the subset of columns
{:database 1
 :query {:source-table 2
         :fields [[:field 9 nil]
                  [:field 7 nil]
                  [:field 2 nil]
                  [:expression "adjective"]]
         :expressions {:adjective ["case"
                                   [[[:> [:field 7 nil] 100]
                                     "expensive"]]
                                   {:default "cheap"}]}}
 :type :query}

If you instead select a subset of fields and then add the custom column, the FE constructs the correct query. So the bug is the transition.

Scenarios:

  • don't specify fields, add custom field, then select subset of fields -> Busted. This is because there is no fields list to keep track of in the select * case, and when it introduces the fields to keep track of it doesn't account for the custom field
  • specify subset of fields, then add custom field. In this code path it is aware of a fields list and adds the custom field to that list and the correct query is created.

@dpsutton dpsutton added .Frontend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness and removed .Needs Triage labels Feb 3, 2022
@alxnddr alxnddr self-assigned this Feb 3, 2022
nemanjaglumac added a commit that referenced this issue Feb 3, 2022
nemanjaglumac added a commit that referenced this issue Feb 4, 2022
@nemanjaglumac nemanjaglumac added the .Reproduced Issues reproduced in test (usually Cypress) label Feb 4, 2022
github-actions bot pushed a commit that referenced this issue Feb 4, 2022
nemanjaglumac added a commit that referenced this issue Feb 4, 2022
…ng subset of fields (#20242) (#20243)

Co-authored-by: Nemanja Glumac <31325167+nemanjaglumac@users.noreply.github.com>
@flamber
Copy link
Contributor

flamber commented Feb 4, 2022

Duplicate of #12395

This was referenced Feb 5, 2024
@replay-io replay-io bot mentioned this issue Apr 24, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.Frontend Priority:P1 Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctness .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants