Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Apr 11, 2024
  2. Apr 10, 2024
  3. Apr 08, 2024
    • Cam Saul's avatar
      Legacy MBQL documentation (#40657) · 6c515648
      Cam Saul authored
      * Legacy MBQL documentation
      
      * Do not commit dox
      
      * Subject the legacy MBQL stuff to the same stricter linting rules as MLv2
      
      * PR feedback
      Unverified
      6c515648
    • Nemanja Glumac's avatar
      Preserve notebook native preview user preferences (#41064) · dd8e0728
      Nemanja Glumac authored
      * Add new user-local setting `notebook-native-preview-preferences`
      
      * Update user settings on FE
      
      * Use two distinct setting entries
      
      * Update FE types
      
      * More explicit `notebook-native-preview-sidebar-width` definition
      
      * Add selectors
      
      * Initialize QB uiControls based on the BE settings
      
      * Rename QB store entry
      
      `isNativePreviewSidebarOpen` -> `isShowingNotebookNativePreview`
      
      * Rename QB store entry
      
      `nativePreviewSidebarWidth` -> `notebookNativePreviewSidebarWidth`
      
      * Add Redux actions
      
      * Dispatch user settings on top of Redux store
      
      * Fix test title typo
      
      * Add E2E test to make sure sidebar is resizable
      
      * Expand the E2E test to cover persisting settings across sessions
      
      * Be more explicit that we're resizing along x axis
      
      * Store window breakpoint as a variable
      
      * Calculate handle's left position more explicitly
      Unverified
      dd8e0728
    • Cal Herries's avatar
  4. Apr 05, 2024
  5. Mar 26, 2024
  6. Mar 25, 2024
  7. Mar 21, 2024
    • Cam Saul's avatar
      Rename `metabase.mbql` to `metabase.legacy-mbql` (#40158) · 0a15637f
      Cam Saul authored
      * Wow
      
      * Test fix :wrench:
      
      * Fixes
      
      * Actions should use strings for column names (fix :update-row and :create-row normalization)
      
      * MLv2 schema should check against keys for the other query type
      
      * Ok, have I fixed things?
      
      * More fixes :wrench:
      
      * Fix indentation
      
      * Another round of test fixes. :wrench:
      
      * Hopefully the last few test fixes :wrench:
      
      * We need to test normalization for queries that have keyword keys as well.
      
      * Fix Cljs i18n namespaces
      
      * Sort namespaces
      
      * Only test against H2
      
      * Rename `metabase.mbql` to `metabase.legacy-mbql`
      
      * Fix Kondo warnings
      
      * Test fixes :wrench:
      
      * Register MBQL clause schemas and test fixes :wrench:
      
      * Test fixes and PR feedback
      
      * Test fix
      
      * Remove the normalization tests
      
      * Test fixes :wrench:
      
      * Fix kondo
      
      * Fix import
      
      * Another fix :wrench:
      
      * Merge
      
      * FIXES
      
      * Add another missing REQUIRE
      Unverified
      0a15637f
  8. Mar 20, 2024
  9. Mar 15, 2024
    • Cam Saul's avatar
      MLv2 normalization overhaul (#40142) · c27b6769
      Cam Saul authored
      * Wow
      
      * Test fix :wrench:
      
      * Fixes
      
      * Actions should use strings for column names (fix :update-row and :create-row normalization)
      
      * MLv2 schema should check against keys for the other query type
      
      * Ok, have I fixed things?
      
      * More fixes :wrench:
      
      * Fix indentation
      
      * Another round of test fixes. :wrench:
      
      * Hopefully the last few test fixes :wrench:
      
      * We need to test normalization for queries that have keyword keys as well.
      
      * Fix Cljs i18n namespaces
      
      * Sort namespaces
      
      * Only test against H2
      
      * Test fixes :wrench:
      
      * Register MBQL clause schemas and test fixes :wrench:
      
      * Test fixes and PR feedback
      
      * Test fix
      Unverified
      c27b6769
  10. Mar 14, 2024
  11. Mar 11, 2024
    • dpsutton's avatar
      Db api (#39731) · 1e7823d1
      dpsutton authored
      * first move to a db api
      
      * mdb.spec into mdb
      
      * mdb.u/isa -> mdb.query/isa
      
      * mdb.u/qualify -> mdb.query/qualify
      
      * last of mbql.u -> mbql.query and :gun:mbql.u:sparkler:
      
      * remove last of the mdb.connection/db-type and use from mdb/db-type
      
      * remove the last non-cmd usages of mdb.connection
      
      had some circularity in
      
      models.interface requires mdb/db-type for sql flavored "now"
      mdb requires db/setup
      which requires db/custom_migrations to ensure they are on cp
      custom migration requires json functions in models.interface
      
      so had to do a dynamic require for the db-type
      
      * get db-type from mdb not mdb.env
      
      * invoke `(mdb/app-db)` and not pass a var. lots of things fail
      
      * mdb.setup/migrate! into mdb with potemkin
      
      * remove get-connection. call .getConnection on the app-db
      
      perhaps invites clumsy usage outside of `with-open` if it's a top level
      function
      
      * namespace docstrings
      
      * last few and grab db.env/db-file into api ns
      
      * lint cleanup
      
      * addresses PR comments
      Unverified
      1e7823d1
  12. Mar 07, 2024
  13. Feb 29, 2024
    • bryan's avatar
      Tech Debt: teamzero (#39417) · b09db3b4
      bryan authored
      * [AS+BCM] fix first 3 todos
      
      * [AS+BCM] add issues
      
      * add jdbc proxy issue
      
      * driver/driver-features -> driver/features
      
      * killing more todos and remove `supports?`
      
      * add more issues
      
      * dont let people who dont have snippet perms access snippets
      
      * adding more issues
      
      * replace calls to support? in mongo driver
      
      * fix namespace sorting
      
      * whitespace
      Unverified
      b09db3b4
  14. Feb 28, 2024
    • Nemanja Glumac's avatar
      Persist user-local info about the last selected database in the native query editor (#38986) · 576e1511
      Nemanja Glumac authored
      * Add new user-specific setting `last-used-database-id`
      
      * Update user settings when user selects a database for a native query
      
      * Remember the last used database in the native query editor
      
      * Fix type error
      
      * Set database id when initializing new native question
      
      * Persist the database only for "New > Native query"
      
      * Persist last used database for native models
      
      * Mark `last-used-database-id` setting as potentially `undefined`
      
      * Reduce diff
      
      * Remove unused prop from QB
      
      * Lift dispatch logic up to the `View` component
      
      * Fix type errors
      
      * Make this setting work for all authenticated users
      
      * Add initial E2E tests
      
      * Add initial backend unit test
      
      * Expand the backend unit test to check for user-local only property
      
      * Fix E2E test and make it more explicit
      
      * Add mongo-related E2E test
      
      * Fix typo
      
      * Add permission-related E2E tests
      
      - Adds reproduction for #39053
      
      * Make sure no redundant requests are made
      
      This commit ensures no redundant requests are made when selecting
      the same, i.e. the previously selected, database.
      
      * Add E2E tests related to model actions
      
      * Clean up
      
      * Extract persist database logic into an action
      
      * Update the setting name as suggested in the code review
      
      * Make the setting description a bit more explicit
      
      * Add one more permissions-based E2E test
      
      * Store postgres database name in a variable
      Unverified
      576e1511
  15. Feb 21, 2024
  16. Feb 20, 2024
  17. Feb 15, 2024
    • Cam Saul's avatar
      Mega QP context and entrypoint overhaul. Reduce QP hairiness by 30% (#35465) · 80dcbdfb
      Cam Saul authored
      * QP enterprise middleware should use `defenterprise`
      
      * Test fix? :wrench:
      
      * Remove `:rff` from the Query Processor context map
      
      * Sort namespaces
      
      * Simplify QP entrypoints part 1
      
      * Test fixes :wrench:
      
      * Test fixes :wrench:
      
      * Make sure defenterprise dispatch is done for every QP run
      
      * B I G  QP context overhaul
      
      * WIP
      
      * Remove qp.context.default
      
      * Test fix :wrench:
      
      * PR feedback
      
      * QP context overhaul [WIP] [ci skip]
      
      * QP context overhaul [WIP] [ci skip]
      
      * Fix duplicate preprocesses
      
      * Some test fixes.
      
      * More test fixes [ci skip]
      
      * Source card resolution middleware should be preprocessing middleware, not around [ci skip]
      
      * Test fixes [WIP] [ci skip]
      
      * Remove `test-qp-middleware`
      
      * Remove `qp/compile`
      
      * Fix Kondo warnings/cleanup
      
      * Remove `mt/compile`
      
      * Fix most tests
      
      * Mostly everything working?
      
      * 4 failures, 1 error
      
      * Eliminate QP context `reducedf`
      
      * 3 failures, 0 errors <3
      
      * All tests are passing <3
      
      * Remove dead debug-qp code
      
      * Fix test failure
      
      * Remove async context
      
      * Remove raisef
      
      * Forget it, just remove context entirely [ci skip]
      
      * Fix Kondo errors
      
      * Fix Kondo warnings
      
      * Fix Kondo warnings
      
      * Fix Kondo warnings
      
      * Remove empty namespace
      
      * Fix some reflection warnings
      
      * Update dox [ci skip]
      
      * Test fix :wrench:
      
      * Fix pivot QP
      
      * Misc improvements
      
      * Test fix :wrench:
      
      * Improvements and test fixes
      
      * More test fixes :wrench:
      
      * Test fixes :wrench:
      
      * Address PR feedback
      
      * Test fixes :wrench:
      
      * More test fixes and docstring improvements
      
      * Appease Eastwood
      
      * Test fixes :wrench:
      
      * More test fixes
      
      * Test fixes :wrench:
      
      
      
      * Revert test parallelization in metabase.models.params.chain-filter-test
      
      * Update src/metabase/async/util.clj
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      ---------
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      Unverified
      80dcbdfb
  18. Feb 13, 2024
  19. Feb 06, 2024
    • Cal Herries's avatar
      Unverified
      a9012596
    • lbrdnk's avatar
      Mongo java driver upgrade (#38017) · 113c0558
      lbrdnk authored
      
      * tmp: patched monger for 4.11.1 mongo java driver
      
      * tmp: Update monger utils
      
      Aggregation probably wont work now, but we are not using those from monger anyway. With this change in place I'm able to load needed namespaces and create test-data dataset successfully.
      
      Commit contains lot of condo errors that should be resolved while porting.
      
      * WIP: Monger removed in favor of java driver wrapper
      
      * Update java driver wrapper
      
      * Update srv test
      
      * Update comments
      
      * Use non keywordized run-command for `dbms-version`
      
      * Fix according to e2e tests
      
      * Cleanup
      
      * Separate `java-driver-wrapper` into multiple namespaces
      
      * Fix semantic type inference for serialized json
      
      * Fix options for run-command
      
      * Cleanup json namespace
      
      * Cleanup conversion namespace
      
      * Cleanup operators
      
      * Update kondo in operators ns
      
      * Cleanup connection namespace
      
      * Cleanup mongo namespace
      
      * Cleanup util namespace
      
      * Add todo
      
      * Move session related code to util
      
      * Cleanup database namespace
      
      * Update docstring for conn string generation
      
      * Update docstrings
      
      * Update tests
      
      * Update linter for with macros
      
      * Update modules/drivers/mongo/src/metabase/driver/mongo/connection.clj
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Update modules/drivers/mongo/src/metabase/driver/mongo/connection.clj
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Use transient in from-document for building a map
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Update can-connect to use let form
      
      - Avoid nested `with-mongo-database` call.
      - Avoid creating a set used for searching for database name.
      
      * Remove redundant set use from describe-database
      
      * Change from-document keywordize default to false
      
      * Remove log message translation
      
      * Update maybe-add-ssl-context-to-builder! to always return builder
      
      * Indent from-document
      
      * Remove redundant ConvertToDocument extensions
      
      * Use oredered-map in do-find's sort
      
      * Use ex-info in details-normalized
      
      * Add imports and update comment in execute ns
      
      * Update fixme comment
      
      * Pass opts instead of a selection to from-document in do-find
      
      * Avoid unnecessary double dot call
      
      * Update connection test ns according to review remarks
      
      * Make tests parallel
      
      * Docstring update
      
      * Update docstring
      
      ---------
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      Unverified
      113c0558
  20. Feb 05, 2024
  21. Jan 29, 2024
  22. Jan 22, 2024
  23. Jan 19, 2024
  24. Jan 18, 2024
  25. Jan 16, 2024
  26. Jan 03, 2024
  27. Dec 27, 2023
  28. Dec 21, 2023
  29. Dec 13, 2023
  30. Dec 11, 2023
    • bryan's avatar
      adding perm-graph filtering on db or group id (#36543) · 19401c1b
      bryan authored
      * a more refined first crack at adding perm-graph access for db or group id
      
      * new routes: filter data-perm-graph on db or group
      
      add tests
      
      * remove inline defs
      
      * code review responses
      
      * fix typo
      
      * fix the other tests
      
      * update the tests to use the right malli schema
      
      * reuse private vars in tests
      
      * pull graph checker into test util ns and apply it
      Unverified
      19401c1b
  31. Dec 07, 2023
    • Mark Bastian's avatar
      Refactoring formatting code for common utility (#36490) · 58f22594
      Mark Bastian authored
      * Apply column formatting to CSV exports
      
      This PR applies the same formatting logic to CSV exports as it does to pulse bodies (e.g. HTML).
      
      Formerly, there were two related formatting paths:
      - `metabase.query-processor.streaming.common/format-value`, which is from a protocol that takes an object and returns a string. It is what was used to export csv data. It applies no actual formatting, only converts objects to strings.
      - `metabase.pulse.render.body/get-format`, which builds a formatter from an optional time zone, column metadata, and visualization settings. This formatter takes a string and formats it. It was only used for rendering inline artifacts, such as embedded HTML in emails.
      
      The first function is insufficient to format row data as it is unaware of the column metadata and viz settings. We need to use that data everywhere data is exported in a uniform way.
      
      The solution is to lift `get-format` from `metabase.pulse.render.body` to a more common location (`metabase.pulse.render.common` in this PR step, but needs to be moved out of the pulse code to be a more shared concern) and use it everywhere artifacts are generated.
      
      For csv export, this was achieved as follows in `metabase.query-processor.streaming.csv`:
      
      ```clojure
      (defmethod qp.si/streaming-results-writer :csv
        [_ ^OutputStream os]
        (let [writer     (BufferedWriter. (OutputStreamWriter. os StandardCharsets/UTF_8))
              formatters (atom {})]
          (reify qp.si/StreamingResultsWriter
            (begin! [_ {{:keys [ordered-cols results_timezone]} :data} viz-settings]
              (swap! formatters (constantly (zipmap
                                              ordered-cols
                                              (map (fn [col]
                                                     (p.common/get-format results_timezone col viz-settings))
                                                   ordered-cols))))
              (csv/write-csv writer [(map (some-fn :display_name :name) ordered-cols)])
              (.flush writer))
      
            (write-row! [_ row _row-num cols {:keys [output-order]}]
              (let [[ordered-row
                     ordered-cols] (if output-order
                                     (let [row-v  (into [] row)
                                           cols-v (into [] cols)]
                                       [(for [i output-order] (row-v i))
                                        (for [i output-order] (cols-v i))])
                                     [row cols])]
                (csv/write-csv writer [(map (fn [c r]
                                              (let [formatter (@formatters c)]
                                                (formatter (common/format-value r))))
                                            ordered-cols ordered-row)])
                (.flush writer)))
      
            (finish! [_ _]
              ;; TODO -- not sure we need to flush both
              (.flush writer)
              (.flush os)
              (.close writer)))))
      ```
      
      The formatters for each column are build in the `begin!` function and then looked up in each `write-row!`.  The existing `format-value` is used to produce a string then passed into our looked up column formatter.
      
      Note that the new unit tests simulate a pulse and grab the provided temp files as attachments and analyzes those for correctness. This should work in a CI environment so long as the test process has permission to both write attachments to the temp directory and read those attachments back out. Also note that these tests can be slow (but not terribly so).
      
      Primary changes:
      - `metabase.email.messages` - fix spelling
      - `metabase.pulse.render.body` - move `get-format` out of this ns
      - `metabase.pulse.render.common` - move `get-format` into this ns
      - `metabase.query-processor.streaming.csv` - new logic to apply pulse renderer formatting to csv exports
      - `metabase.pulse.pulse-integration-test` - adding unit tests
      
      One TODO before a final commit of this PR is to move the `get-format` logic out of a pulse ns into something more general. Ultimately, it would be nice if this was a common capability used by both BE and FE.
      
      * Refactoring formatting code for common utility
      
      This PR refactors `metabase.pulse.render.common` to `metabase.formatter` as this is code we want applied to several locations, not just in pulses. It also updates references to these nses and the consistent alias.
      
      A key observation of this formatting code, and reason for the refactor, is that it is "metabase-aware" in that it takes into account metadata columns and visualization settings when building formatters rather than just being a simple generic date or number formatter. This is a common code path that should be used any time we are rendering static assets and could potentially be used as common FE code with future development.
      
      Moves:
      - `metabase.pulse.render.common` to `metabase.formatter`
      - `metabase.pulse.render.datetime` to `metabase.formatter.datetime`
      - `metabase.pulse.render.common-test` to `metabase.formatter-test`
      - `metabase.pulse.render.datetime-test` to `metabase.formatter.datetime-test`
      
      * Ordering consistent aliases in kondo config
      
      * Rebase fix to use formatter ns in streaming.csv
      
      * Adding `metabase.formatter` require.
      
      * Updating require alias on new test.
      Unverified
      58f22594
  32. Dec 05, 2023
  33. Dec 01, 2023
    • Mark Bastian's avatar
      Document and test adding `results_metadata` to qp middleware for static viz (#36245) · 06848968
      Mark Bastian authored
      * Adding results_metadata to qp middleware
      
      This adds two middlewares to `metabase.query-processor.middleware.results-metadata`:
      - `inject-result-metadata`: Adds `result_metadata` from the context, if present, into the query map during preprocessing.
      - `merge-existing-metadata`: A post-processing middleware that merges `results_metadata` (if present) from the query data into the metadata.
      
      This has the effect of preserving existing metadata, which is particularly important for user-curated metadata, such as semantic type overrides.
      
      This may also facilitate addressing the following TODO in the same ns:
      
      ```
      ;; 1. Is there some way we could avoid doing this every single time a Card is ran? Perhaps by passing the current Card
      ;;    metadata as part of the query context so we can compare for changes
      ```
      
      * Preserving result_metadata in query processor
      
      This PR uses `qp.util/combine-metadata` to simplify the combination of provided `:result_metadata` with computed metadata. It also updates pulse rendering code to use this new code path and adds and updates tests to vet this logic.
      
      * fmt
      
      * Modifying PR to document and use existing fns
      
      The current qp pipeline will correctly propagate custom metadata if a question is derived from a model or if the model is processed like so:
      
      ```clojure
      (qp/process-query
        (assoc-in dataset_query [:info :metadata/dataset-metadata] result_metadata))
      ```
      
      This PR fixes rendering unit tests to clarify this and provides a much better working example in the `dev.render-png` ns.
      
      * Updating test
      
      * Adding Pulse w/Metadata Tests
      
      This pr adds a unit test that constructs a dashboard and simulates a pulse email, then checks the resulting HTML for correctness.
      
      A dependency on the [hickory](https://github.com/clj-commons/hickory) library was added to dev. This allows us to easily parse HTML into data and navigate the parse tree.
      
      Note that it does NOT check the attachments for formatting correctness.
      
      Spelling and import consistency changes were also made.
      Unverified
      06848968
  34. Nov 16, 2023
Loading