Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Dec 10, 2021
    • Cam Saul's avatar
      Big QP parameter refactor; validate param :types for Cards (#19188) · 0c4be936
      Cam Saul authored
      * Refactor: move Card and Dashboard QP code into their own qp.* namespaces
      
      * Disable extra validation for now so a million tests don't fail
      
      * WIP
      
      * Validate template tag :parameters in query in context of a Card
      
      * Fixes
      
      * Disable strict validation for now
      
      * Test fixes [WIP]
      
      * Make the parameter type schema a little more forgiving for now
      
      * Tests & test fixes :wrench:
      
      * More test fixes :wrench:
      
      * 1. Need more tests
      2. Need to actually validate stuff
      
      * More test fixes. :wrench:
      
      * Test fixes (again)
      
      * Test fix :wrench:
      
      * Some test fixes / PR feedback
      
      * Disallow native queries with a tag widget-type of "none"
      
      Template tags with a widget-type that is undefined, null, or "none" now
      cause the query's isRunnable method to return false. Existing questions
      that have this defect won't be runnable until they are resaved with a
      set widget-type.
      
      * Fix prettier error
      
      * add snippet and card types to validation pass
      
      * Make sure template tag map keys + `:names` agree + test fixes
      
      * Have MBQL normalization reconcile template tags map key and :name
      
      * Test fix :wrench:
      
      * Fix tests for Cljs
      
      * Fix Mongo tests.
      
      * Allow passing :category parameters for :text/:number/:date for now.
      
      * Dashboard subscriptions should use qp.dashboard code for executing
      
      * Make sure Dashboard QP parameter resolution code merges in default values
      
      * Add a test for sending a test Dashboard subscription with default params
      
      * Prettier
      
      * If both Dashboard and Card have default param value, prefer Card's default
      
      * Test fix :wrench:
      
      * More tests and more fixes :cry:
      
      
      
      Co-authored-by: default avatarDalton Johnson <daltojohnso@users.noreply.github.com>
      0c4be936
    • Alexander Polyankin's avatar
  2. Dec 09, 2021
  3. Dec 08, 2021
    • Howon Lee's avatar
      Combo / Multi chart static viz BE (#19151) · e3388f14
      Howon Lee authored
      Combo type and multiple cards for static viz BE. These go into one FE endpoint but are two really separate things in BE. This one conforms to the FE type but the price is that the previous more-dynamic BE types needed to be changed to conform: this will require a refactoring to whack the js-viz types that already exist, when the FE is refactored also.
      e3388f14
  4. Dec 07, 2021
    • Ben Cook's avatar
      Fix small typos in docstrings (#19170) · f2015527
      Ben Cook authored
      f2015527
    • dpsutton's avatar
      Only select type information on type inference of coalesce (#19008) · a2dfc160
      dpsutton authored
      * Only select type information on type inference of coalesce
      
      This previously just selected hte inferred information from the second
      argument to the coalesce. For fields this would return the entire field
      object which includes an id.
      
      Later, in `source-metadata->fields` this assumes that since an id is
      present, we should select `[:field id nil]`, but this confused that the
      type of the coalesce column is the same as that field-id, not that we
      want to select that field id.
      
      ```clojure
      add-source-metadata=> (pprint
                              (mbql-source-query->metadata {:source-table 2
                                                            :joins [{:fields [[:field
                                                                               22
                                                                               {:join-alias "People - User"}]
                                                                              [:field
                                                                               15
                                                                               {:join-alias "People - User"}]]
                                                                     :source-table 3
                                                                     :condition [:=
                                                                                 [:field 3 nil]
                                                                                 [:field
                                                                                  22
                                                                                  {:join-alias "People - User"}]]
                                                                     :alias "People - User"}]
                                                            :expressions {:coalesce [:coalesce
                                                                                     [:field 3 nil]
                                                                                     [:field
                                                                                      22
                                                                                      {:join-alias "People - User"}]]}
                                                            :aggregation [[:count]]
                                                            :breakout [[:expression "coalesce"]]}))
      ({:semantic_type :type/FK,
        :table_id 2,
        :coercion_strategy nil,
        :name "coalesce",                    ;; merging maintains the correct name
        :settings nil,
        :field_ref [:expression "coalesce"], ;; merging maintains the field ref
        :effective_type :type/Integer,
        :parent_id nil,
        :id 3,                               ;; the type inference selected
                                             ;; the entire field, including its id
        :display_name "coalesce",
        :fingerprint {:global {:distinct-count 929, :nil% 0.0}},
        :base_type :type/Integer}
       {:name "count",
        :display_name "Count",
        :base_type :type/BigInteger,
        :semantic_type :type/Quantity,
        :field_ref [:aggregation 0]})
      nil
      ```
      
      updating to only select the type information:
      
      ```clojure
      add-source-metadata=> (pprint
                              (mbql-source-query->metadata {:source-table 2
                                                            :joins [{:fields [[:field
                                                                               22
                                                                               {:join-alias "People - User"}]
                                                                              [:field
                                                                               15
                                                                               {:join-alias "People - User"}]]
                                                                     :source-table 3
                                                                     :condition [:=
                                                                                 [:field 3 nil]
                                                                                 [:field
                                                                                  22
                                                                                  {:join-alias "People - User"}]]
                                                                     :alias "People - User"}]
                                                            :expressions {:coalesce [:coalesce
                                                                                     [:field 3 nil]
                                                                                     [:field
                                                                                      22
                                                                                      {:join-alias "People - User"}]]}
                                                            :aggregation [[:count]]
                                                            :breakout [[:expression "coalesce"]]}))
      ({:name "coalesce",
        :display_name "coalesce",
        :base_type :type/Integer,
        :effective_type :type/Integer,  ;; no more field information beyond
                                        ;; the types
        :coercion_strategy nil,
        :semantic_type :type/FK,
        :field_ref [:expression "coalesce"]}
       {:name "count",
        :display_name "Count",
        :base_type :type/BigInteger,
        :semantic_type :type/Quantity,
        :field_ref [:aggregation 0]})
      ```
      
      * Update question in repro now that it doesn't fail on the backend
      
      previously this question would actually fail on the backend and
      independently the frontend would go into a stack overflow killing the
      page. Fixing the bug actually broke the test as it asserted that the
      query would break and look for the error message. Now that the query
      returns assert we can find the name of the question "test question"
      
      * Correct same bug for case
      
      When inferring type for a case, we were returning the type information
      for the first field we could find in the case statement. And that
      information included the field id. We always merge the current column's
      name on top of that to remove the analyzed field's name and other
      things, but the field-id would remain. `source-metadata->fields` in
      add_implicit_clauses will add a field reference if it finds a field id.
      
      Before, the following was returned
      
      ```clojure
      ({:description "The date and time an order was submitted."
        :semantic_type :type/CreationTimestamp
        :table_id 2
        :coercion_strategy nil
        :unit :month
        :name "CREATED_AT"
        :settings nil
        :source :breakout
        :field_ref [:field
                    4
                    {:temporal-unit :month}]
        :effective_type :type/DateTime
        :parent_id nil
        :id 4
        :visibility_type :normal
        :display_name "Created At"
        :fingerprint {:global {:distinct-count 9998
                               :nil% 0.0}
                      :type {:type/DateTime {:earliest "2016-04-30T18:56:13.352Z"
                                             :latest "2020-04-19T14:07:15.657Z"}}}
        :base_type :type/DateTime}
       {:description "The raw, pre-tax cost of the order. Note that this might be different in the future from the product price due to promotions, credits, etc."
        :semantic_type :type/Quantity
        :table_id 2
        :coercion_strategy nil
        :name "distinct case"
        :settings nil
        :source :aggregation
        :field_ref [:aggregation 0]
        :effective_type :type/Float
        :parent_id nil
        :id 6
        :visibility_type :normal
        :display_name "distinct case"
        :fingerprint {:global {:distinct-count 340
                               :nil% 0.0}
                      :type {:type/Number {:min 15.691943673970439
                                           :q1 49.74894519060184
                                           :q3 105.42965746993103
                                           :max 148.22900526552291
                                           :sd 32.53705013056317
                                           :avg 77.01295465356547}}}
        :base_type :type/BigInteger})
      ```
      
      The important bit above is that the metadata for the "distinct case" has
      the correct field_ref but also has a field id.
      
      After, we now return the following metadata:
      ```clojure
      ({:description "The date and time an order was submitted."
        :semantic_type :type/CreationTimestamp
        :table_id 2
        :coercion_strategy nil
        :unit :month
        :name "CREATED_AT"
        :settings nil
        :source :fields
        :field_ref [:field
                    4
                    {:temporal-unit :default}]
        :effective_type :type/DateTime
        :parent_id nil
        :id 4
        :visibility_type :normal
        :display_name "Created At"
        :fingerprint {:global {:distinct-count 9998
                               :nil% 0.0}
                      :type {:type/DateTime {:earliest "2016-04-30T18:56:13.352Z"
                                             :latest "2020-04-19T14:07:15.657Z"}}}
        :base_type :type/DateTime}
       {:base_type :type/BigInteger
        :effective_type :type/Float
        :coercion_strategy nil
        :semantic_type :type/Quantity
        :name "distinct case"
        :display_name "distinct case"
        :source :fields
        :field_ref [:field
                    "distinct case"
                    {:base-type :type/BigInteger}]}
       {:semantic_type :type/Quantity
        :coercion_strategy nil
        :name "cc"
        :expression_name "cc"
        :source :fields
        :field_ref [:expression "cc"]
        :effective_type :type/Float
        :display_name "cc"
        :base_type :type/Float})
      ```
      
      * Add tests looking for full field analysis without id
      a2dfc160
  5. Dec 06, 2021
  6. Dec 03, 2021
    • Jeff Evans's avatar
      Secrets :closed_lock_with_key: PR 7 - Enable Postgres driver to use secrets for configuring SSL parameters (#18968) · f8d712d6
      Jeff Evans authored
      * Enable Postgres driver to use secrets for configuring SSL parameters
      
      Adding secret related properties for SSL options to Postgres driver
      
      Move `conn-props->secret-props-by-name` to secret.clj since it's needed directly there, too
      
      Add `us-east-2-bundle.pem` to `test-resources/certificates` for testing Postgres with SSL connectivity to our RDS instance (and a README.md explaining how it differs from the existing `ssl` directory)
      
      Updating `value->file!` to have better logic for building the error message when the existing file is not found (for better UX from the Database admin page)
      
      Updating frontend to support the `visible-if` value being an array, in which case any value may match the current details value, in order for that field to be visible
      
      Adding secret related properties for SSL options to Postgres driver
      
      Updating CircleCI config.yml to refer to the RDS instance when running Postgres SSL test
      
      Implement server side expansion of transitive visible-if dependency chain
      
      Update shouldShowEngineProvidedField on client to consider multiple key/value pairs in the visible-if map, and only show the field if ALL are true
      
      Adding new test to confirm transitive visible-if resolution, and cycle detection
      
      Add Cypress test for SSL field visibility
      f8d712d6
    • Noah Moss's avatar
      Snowplow backend integration (#18784) · efab1e44
      Noah Moss authored
      efab1e44
    • Noah Moss's avatar
    • Noah Moss's avatar
      f1606cb2
  7. Dec 02, 2021
  8. Dec 01, 2021
  9. Nov 30, 2021
    • Jeff Evans's avatar
      Limit autocomplete results for tables and fields (#19066) · 4137054d
      Jeff Evans authored
      * Limit autocomplete results for tables and fields
      
      Add limit of 50 total fields or tables returned from the autocomplete_suggestions API, which can be a mixture of tables and/or fields
      
      Adding test that confirms results are limited properly
      4137054d
  10. Nov 28, 2021
  11. Nov 23, 2021
  12. Nov 22, 2021
  13. Nov 17, 2021
    • Jeff Evans's avatar
      Secrets :closed_lock_with_key: PR 6 - Update Oracle properties (#18320) · 0480c2cc
      Jeff Evans authored
      
      * Add SSL keystore and truststore secret properties to Oracle driver YAML files
      
      
      Update Oracle driver to set keystore and truststore connection options from secret values
      
      Adding new `select-keys-sequentially` helper function for dealing with assertions on transformed conn props
      
      Add new function to the secret namespace to return a lighter weight "secret map", and remove that functionality from the `handle-db-details-secret-prop!`, so that it can be reused from connection testing
      
      Modifying CircleCI to set the corresponding truststore secret conn prop vars instead of JVM-level truststore settings, as the test had been doing previously
      
      Expand Oracle test connection details to incorporate all SSL related properties, and also make it a function instead of delayed def (so changes can be picked up later)
      
      Misc. fixes in Oracle driver YAML files
      
      Update `exception-classes-not-to-retry` to include SSLHandshakeException
      
      Fix misc issues in secret and database model code
      
      Update CircleCI config to use correct secret based env var keys and values
      
      Add *database-name-override* dynamic var in `metabase.test.data.interface` to allow for DB name overriding
      
      Fix up ssl connectivity test so all parts pass successfully
      
      Get rid of crazy with-redefs to swap in the existing test-data's schema, and instead, just dropping the DB if it was created under a different schema (similar to what H2 does)
      
      Co-authored-by: default avatarGustavo Saiani <gustavo@poe.ma>
      0480c2cc
  14. Nov 15, 2021
  15. Nov 12, 2021
  16. Nov 11, 2021
    • dpsutton's avatar
      Map tiles improvements (#18912) · 1c70882b
      dpsutton authored
      * Speed up interger or string recognition
      
      jeff helpfully pointed this out. I did some repl benchmarks
      
      ```clojure
      (comment
        (doseq [x ["3" "bob"]]
          (dotimes [_ 3] (time (dotimes [_ 10000] (try (Integer/parseInt x)
                                                        (catch NumberFormatException _ x))))))
        (doseq [x ["3" "bob"]]
          (dotimes [_ 3] (time (dotimes [_ 10000] (if (re-matches #"\d+" x)
                                                    (Integer/parseInt x)
                                                    x))))))
      
      tiles-test=> (doseq [x ["3" "bob"]]
                     (dotimes [_ 3] (time (dotimes [_ 10000] (try (Integer/parseInt x)
                                                                  (catch NumberFormatException _ x))))))
      "Elapsed time: 5.72825 msecs"
      "Elapsed time: 1.531042 msecs"
      "Elapsed time: 0.797041 msecs"
      "Elapsed time: 32.120875 msecs"
      "Elapsed time: 27.848375 msecs"
      "Elapsed time: 23.820542 msecs"
      nil
      tiles-test=> (doseq [x ["3" "bob"]]
                     (dotimes [_ 3] (time (dotimes [_ 10000] (if (re-matches #"\d+" x)
                                                               (Integer/parseInt x)
                                                               x)))))
      "Elapsed time: 5.356417 msecs"
      "Elapsed time: 1.97225 msecs"
      "Elapsed time: 1.868708 msecs"
      "Elapsed time: 1.214666 msecs"
      "Elapsed time: 1.185625 msecs"
      "Elapsed time: 1.19025 msecs"
      nil
      tiles-test=>
      ```
      
      * Only select lat/lon fields in api/tiles
      
      We required the index of lat and long columns, ran the whole query, and
      then just grabbed those columns in a `(for [row rows] [(nth row
      lat-idx)..])`. But of course we can just update the fields we want to
      select in the query.
      
      MBQL and native queries flow through this codepath depending on the
      source of the query of the card being mapped. For mbql queries, it is
      straightforward, add a filter on the lat long and replace the fields
      with just lat and long fields. For native, we nest the native query as a
      nested query and then proceed on the resulting mbql query. The only
      difference is requiring the type annotation for the field type.
      
      mbql field: [:field 32 nil] vs [:field "latitude" {:base-type :type/Float}]
      
      This addresses memory concerns. The query is not limited and we don't
      need to select an entire row for these purposes. Dropping lots of text
      fields, id fields, etc could save quite a bit of memory when resolving
      the entire result set in memory.
      
      * Add limit to number of coordinates per tile
      
      these queries were unbounded in getting coordinates for each tile. But
      in a visualization, can there really be more information provided? We
      were leaving them unbounded and getting back millions of rows (reported
      on #4844). So we were adding unnecessary detail at the price of OOM
      errors.
      
      Note tests have been changed to show that the limit of the original mbql
      query is clobbered and the limit of the original native query is only
      present in the nested query whereas the outer query selects its own
      limit.
      
      As always, should this number be exposed as a setting? Configurable in
      the UI? Leaving as a hardcoded and documented number for the moment.
      
      * docstring
      
      * Remove col indices from api/tiles
      
      since we just select the actual columns we want, we no longer need the
      index in the results of those cols. they are always the first and second
      columns
      
      * Trim final slash on url
      1c70882b
    • dpsutton's avatar
      Nest qbnewb under /modal to allow for other modals (#18926) · 11d9bd55
      dpsutton authored
      * Nest qbnewb under /modal to allow for other modals
      
      move the api from api/user/:id/qbnewb -> api/user/:id/modal/qbnewb to
      allow for the upcoming new dismissable modal
      
      * Add additional datasetnewb route
      
      staying with the same naming scheme as qbnewb. the db field is
      is_datasetnewb, the route just takes datasetnewb.
      
      I'm not wild about the default is true, set to false, and the naming
      scheme. But will be easier to migrate and easier for FE to use if we
      continue the defaults/logic etc.
      
      * Remark on db change in migration file
      11d9bd55
  17. Nov 10, 2021
  18. Nov 09, 2021
    • Jeff Evans's avatar
      Secrets :closed_lock_with_key: PR 5 - Translate secret connection-properties into existing types... · 13e9414b
      Jeff Evans authored
      Secrets :closed_lock_with_key: PR 5 - Translate secret connection-properties into existing types understood by frontend (#18236)
      
      * Translate secret connection-properties into existing types understood by frontend
      
      For all :type :secret properties, before returning over the wire (i.e. from `available-drivers-info`), translate the connection-property into one or more new client side properties, using the existing types, to encapsulate the behavior of that individual secret "unit".  Depending on the :secret-kind and hosting environment, this could mean there are multiple additional properties injected (one for the file upload versus local path option field, one for the value itself on upload, and one for the file path)
      
      Adding utility function to do the reverse (i.e. translating those client side properties back to the server secret property definition)
      
      Adding tests for both (including updating secret-test-driver to cover all of these)
      
      Add support for the treat-before-posting connection property config
      
      * Fix bug in `delete-orphaned-secrets!`
      13e9414b
  19. Nov 08, 2021
Loading