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

Error with relative date filters on custom column #16273

Closed
mazameli opened this issue May 27, 2021 · 5 comments · Fixed by #19054
Closed

Error with relative date filters on custom column #16273

mazameli opened this issue May 27, 2021 · 5 comments · Fixed by #19054
Assignees
Labels
Priority:P2 Average run of the mill bug Querying/Notebook/Custom Column Querying/Parameters & Variables Filter widgets, field filters, variables etc. .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects
Milestone

Comments

@mazameli
Copy link
Contributor

This was in Safari, running EE on master locally. I encountered an error with relative date filters, trying to filter on a custom column defined by case([Discount]>0, [Created At], [Product → Created At])

  1. Ask a question, Custom question
  2. Sample Dataset, Orders table
  3. Custom Column, type case([Discount]>0, [Created At], [Product → Created At]) and call it MiscDate
  4. Filter, choose the new MiscDate column
  5. Use the Previous 30 days filter
  6. Click the Preview button next to the Filter step
  7. See error message:

Value does not match schema: {:query {:filter (named [nil (named [(named (not (= :field :expression)) :field) nil (not (present? "options"))] "field") nil nil nil] "Must be a valid instance of one of these clauses: :and, :or, :not, :=, :!=, :<, :>, :<=, :>=, :between, :starts-with, :ends-with, :contains, :does-not-contain, :inside, :is-empty, :not-empty, :is-null, :not-null, :time-interval, :segment")}}

image

@mazameli mazameli added Type:Bug Product defects Priority:P2 Average run of the mill bug Querying/Notebook Items specific to the Custom/Notebook query builder .bugbash labels May 27, 2021
@nemanjaglumac
Copy link
Member

nemanjaglumac commented May 28, 2021

@mazameli please include the details about your Metabase installation (at least the branch) in the future. I spent at least 10-15 minutes wondering why I can't reproduce this, only to realize it is on master and I was trying on a release branch.

Thanks

@flamber

This comment has been minimized.

@nemanjaglumac nemanjaglumac added the .Reproduced Issues reproduced in test (usually Cypress) label May 28, 2021
@rlotun
Copy link
Contributor

rlotun commented Sep 13, 2021

is this fixed now?

@flamber
Copy link
Contributor

flamber commented Sep 13, 2021

No.

Describe the bug
When a Custom Column is a date, then it's not possible to filter it by relative (Previous, Next or Current) period.

To Reproduce

  1. Custom question > Sample Dataset > Products
  2. Custom Column [Created At] as "CC"
  3. Filter "CC" by relative (Previous, Next or Current) period
    image
  4. Visualize, will error with
    Value does not match schema: {:query {:filter (named [nil (named [(named (not (= :field :expression)) :field) nil (not (present? "options"))] "field") nil nil nil] "Must be a valid instance of one of these clauses: :and, :or, :not, :=, :!=, :<, :>, :<=, :>=, :between, :starts-with, :ends-with, :contains, :does-not-contain, :inside, :is-empty, :not-empty, :is-null, :not-null, :time-interval, :segment")}}
Full stacktrace
2021-09-09 09:29:53,770 ERROR middleware.catch-exceptions :: Error processing query: null
{:database_id 4,
 :started_at #t "2021-09-09T09:29:53.350221+02:00[Europe/Copenhagen]",
 :error_type :invalid-query,
 :json_query
 {:type "query",
  :query
  {:source-table 10,
   :expressions {:CC ["field" 108 nil]},
   :filter ["time-interval" ["expression" "CC"] -30 "year" {}]},
  :database 4,
  :parameters [],
  :middleware {:js-int-to-string? true, :add-default-userland-constraints? true}},
 :native nil,
 :status :failed,
 :class clojure.lang.ExceptionInfo,
 :stacktrace
 ["--> util.schema$schema_core_validator$fn__16485.invoke(schema.clj:29)"
  "query_processor.middleware.validate$validate_query$fn__50036.invoke(validate.clj:9)"
  "query_processor.middleware.normalize_query$normalize$fn__47915.invoke(normalize_query.clj:22)"
  "query_processor.middleware.add_rows_truncated$add_rows_truncated$fn__45181.invoke(add_rows_truncated.clj:35)"
  "query_processor.middleware.results_metadata$record_and_return_metadata_BANG_$fn__49967.invoke(results_metadata.clj:147)"
  "query_processor.middleware.constraints$add_default_userland_constraints$fn__47032.invoke(constraints.clj:42)"
  "query_processor.middleware.process_userland_query$process_userland_query$fn__49078.invoke(process_userland_query.clj:134)"
  "query_processor.middleware.catch_exceptions$catch_exceptions$fn__46972.invoke(catch_exceptions.clj:173)"
  "query_processor.reducible$async_qp$qp_STAR___38255$thunk__38256.invoke(reducible.clj:103)"
  "query_processor.reducible$async_qp$qp_STAR___38255.invoke(reducible.clj:109)"
  "query_processor.reducible$sync_qp$qp_STAR___38264$fn__38267.invoke(reducible.clj:135)"
  "query_processor.reducible$sync_qp$qp_STAR___38264.invoke(reducible.clj:134)"
  "query_processor$process_userland_query.invokeStatic(query_processor.clj:241)"
  "query_processor$process_userland_query.doInvoke(query_processor.clj:237)"
  "query_processor$fn__50126$process_query_and_save_execution_BANG___50135$fn__50138.invoke(query_processor.clj:253)"
  "query_processor$fn__50126$process_query_and_save_execution_BANG___50135.invoke(query_processor.clj:245)"
  "query_processor$fn__50170$process_query_and_save_with_max_results_constraints_BANG___50179$fn__50182.invoke(query_processor.clj:265)"
  "query_processor$fn__50170$process_query_and_save_with_max_results_constraints_BANG___50179.invoke(query_processor.clj:258)"
  "api.dataset$run_query_async$fn__56417.invoke(dataset.clj:56)"
  "query_processor.streaming$streaming_response_STAR_$fn__56396$fn__56397.invoke(streaming.clj:72)"
  "query_processor.streaming$streaming_response_STAR_$fn__56396.invoke(streaming.clj:71)"
  "async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:65)"
  "async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:63)"
  "async.streaming_response$do_f_async$fn__16088.invoke(streaming_response.clj:84)"],
 :context :ad-hoc,
 :error
 "Value does not match schema: {:query {:filter (named [nil (named [(named (not (= :field :expression)) :field) nil (not (present? \"options\"))] \"field\") nil nil nil] \"Must be a valid instance of one of these clauses: :and, :or, :not, :=, :!=, :<, :>, :<=, :>=, :between, :starts-with, :ends-with, :contains, :does-not-contain, :inside, :is-empty, :not-empty, :is-null, :not-null, :time-interval, :segment\")}}",
 :row_count 0,
 :running_time 0,
 :preprocessed nil,
 :ex-data
 {:type :schema.core/error,
  :value
  {:type :query,
   :query
   {:source-table 10, :expressions {:CC [:field 108 nil]}, :filter [:time-interval [:expression "CC"] -30 :year nil]},
   :database 4,
   :middleware {:js-int-to-string? true, :add-default-userland-constraints? true},
   :info
   {:executed-by 1,
    :context :ad-hoc,
    :nested? false,
    :query-hash
    [-101, 61, 16, 88, 56, -102, 66, -76, -34, -51, 81, 49, -91, 28, 80, -47, -35, -115, 5, -15, -23, 24, 17, 111, 11,
     112, 59, 16, 123, -30, 14, -73]},
   :constraints {:max-results 10000, :max-results-bare-rows 2000}},
  :error
  {:query
   {:filter
    (named [nil (named [(named (not (= :field :expression)) :field) nil (not (present? "options"))] "field") nil nil nil] "Must be a valid instance of one of these clauses: :and, :or, :not, :=, :!=, :<, :>, :<=, :>=, :between, :starts-with, :ends-with, :contains, :does-not-contain, :inside, :is-empty, :not-empty, :is-null, :not-null, :time-interval, :segment")}}},
 :data {:rows [], :cols []}}

2021-09-09 09:29:53,788 DEBUG middleware.log :: POST /api/dataset 202 [ASYNC: completed] 444.2 ms (3 DB calls) App DB connections: 0/7 Jetty threads: 3/50 (1 idle, 0 queued) (69 total active threads) Queries in flight: 0 (0 queued)

Information about your Metabase Installation:
Tested 0.40.0 thru 0.40.4 and master 6e046fb

Additional context
We didn't support inference until 0.40.0 (reference #15952)
Likely related to #17775 and #17807

@nemanjaglumac
Copy link
Member

FYI, This issue has a ".Reproduced" label, but the e2e repro wasn't skipped in the PR that closed it.

This was referenced May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:P2 Average run of the mill bug Querying/Notebook/Custom Column Querying/Parameters & Variables Filter widgets, field filters, variables etc. .Reproduced Issues reproduced in test (usually Cypress) Type:Bug Product defects
Projects
Cypress Testing
Awaiting triage
6 participants