Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Sep 26, 2023
  2. Sep 25, 2023
  3. Sep 22, 2023
    • Nemanja Glumac's avatar
      Do not offer to delete archived collections (#33991) · 14d4665c
      Nemanja Glumac authored
      * Reproduce #33996
      Unverified
      14d4665c
    • Case Nelson's avatar
      [MLv2] Add query can-run function (#34040) · 20988e95
      Case Nelson authored
      
      * [MLv2] Add query can-run function
      
      * Update src/metabase/lib/native.cljc
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Add test for non-native query
      
      * Fix tests - snippet-id can be optional
      
      ---------
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      Unverified
      20988e95
    • dpsutton's avatar
      ~~Bump h2~~ inline parameter to fix flaky test (#34062) · fa764262
      dpsutton authored
      * Bump h2 to fix flaky test
      
      Symptom:
      --------
      
      error in linter job:
      ```
      With premium token features = #{"audit-app"}
      :metabase-enterprise.audit-app.pages.dashboards/most-popular-with-avg-speed
      
      expected: (schema= {:status (s/eq :completed), s/Keyword s/Any} (qp/process-query query))
        actual: clojure.lang.ExceptionInfo: Error reducing result rows: Error running audit query: Invalid value "NULL" for parameter "result FETCH"; SQL statement:
      WITH "MOST_POPULAR" AS (SELECT "D"."ID" AS "DASHBOARD_ID", "D"."NAME" AS "DASHBOARD_NAME", COUNT(*) AS "VIEWS" FROM "VIEW_LOG" AS "VL" LEFT JOIN "REPORT_DASHBOARD" AS "D" ON "VL"."MODEL_ID" = "D"."ID" WHERE "VL"."MODEL" = 'dashboard' GROUP BY "D"."ID" ORDER BY COUNT(*) DESC LIMIT ?), "CARD_RUNNING_TIME" AS (SELECT "QE"."CARD_ID", AVG("QE"."RUNNING_TIME") AS "AVG_RUNNING_TIME" FROM "QUERY_EXECUTION" AS "QE" WHERE "QE"."CARD_ID" IS NOT NULL GROUP BY "QE"."CARD_ID"), "DASH_AVG_RUNNING_TIME" AS (SELECT "D"."ID" AS "DASHBOARD_ID", AVG("RT"."AVG_RUNNING_TIME") AS "AVG_RUNNING_TIME" FROM "REPORT_DASHBOARDCARD" AS "DC" LEFT JOIN "CARD_RUNNING_TIME" AS "RT" ON "DC"."CARD_ID" = "RT"."CARD_ID" LEFT JOIN "REPORT_DASHBOARD" AS "D" ON "DC"."DASHBOARD_ID" = "D"."ID" WHERE "D"."ID" IN (SELECT "DASHBOARD_ID" FROM "MOST_POPULAR") GROUP BY "D"."ID") SELECT "MP"."DASHBOARD_ID", "MP"."DASHBOARD_NAME", "MP"."VIEWS", "RT"."AVG_RUNNING_TIME" FROM "MOST_POPULAR" AS "MP" LEFT JOIN "DASH_AVG_RUNNING_TIME" AS "RT" ON "MP"."DASHBOARD_ID" = "RT"."DASHBOARD_ID" ORDER BY "MP"."VIEWS" DESC LIMIT ? [90008-214]
      
      <stack traces of us catching and rethrowing>
      Caused by: org.h2.jdbc.JdbcSQLDataException: Invalid value "NULL" for parameter "result FETCH"; SQL statement:
      WITH "MOST_POPULAR" AS (SELECT "D"."ID" AS "DASHBOARD_ID", "D"."NAME" AS "DASHBOARD_NAME", COUNT(*) AS "VIEWS" FROM "VIEW_LOG" AS "VL" LEFT JOIN "REPORT_DASHBOARD" AS "D" ON "VL"."MODEL_ID" = "D"."ID" WHERE "VL"."MODEL" = 'dashboard' GROUP BY "D"."ID" ORDER BY COUNT(*) DESC LIMIT ?), "CARD_RUNNING_TIME" AS (SELECT "QE"."CARD_ID", AVG("QE"."RUNNING_TIME") AS "AVG_RUNNING_TIME" FROM "QUERY_EXECUTION" AS "QE" WHERE "QE"."CARD_ID" IS NOT NULL GROUP BY "QE"."CARD_ID"), "DASH_AVG_RUNNING_TIME" AS (SELECT "D"."ID" AS "DASHBOARD_ID", AVG("RT"."AVG_RUNNING_TIME") AS "AVG_RUNNING_TIME" FROM "REPORT_DASHBOARDCARD" AS "DC" LEFT JOIN "CARD_RUNNING_TIME" AS "RT" ON "DC"."CARD_ID" = "RT"."CARD_ID" LEFT JOIN "REPORT_DASHBOARD" AS "D" ON "DC"."DASHBOARD_ID" = "D"."ID" WHERE "D"."ID" IN (SELECT "DASHBOARD_ID" FROM "MOST_POPULAR") GROUP BY "D"."ID") SELECT "MP"."DASHBOARD_ID", "MP"."DASHBOARD_NAME", "MP"."VIEWS", "RT"."AVG_RUNNING_TIME" FROM "MOST_POPULAR" AS "MP" LEFT JOIN "DASH_AVG_RUNNING_TIME" AS "RT" ON "MP"."DASHBOARD_ID" = "RT"."DASHBOARD_ID" ORDER BY "MP"."VIEWS" DESC LIMIT ? [90008-214]
       at org.h2.message.DbException.getJdbcSQLException (DbException.java:646)
          org.h2.message.DbException.getJdbcSQLException (DbException.java:477)
          org.h2.message.DbException.get (DbException.java:223)
          org.h2.message.DbException.getInvalidValueException (DbException.java:298)
          org.h2.command.query.Query.getOffsetFetch (Query.java:912)
          org.h2.command.query.Select.queryWithoutCache (Select.java:768)
          org.h2.command.query.Query.queryWithoutCacheLazyCheck (Query.java:197)
          org.h2.command.query.Query.query (Query.java:512)
          ...
      ```
      
      BUT this only causes an issue for tests run under the cloverage
      linter. It's not an issue under any other test scenarios.
      
      Reproduction:
      -------------
      
      I can get the same stack traces with the following:
      
      ```clojure
      dashboards=> (clojure.java.jdbc/query {:datasource
                                             (:data-source metabase.db.connection/*application-db*)}
                                            ["select 1 limit null"])
      Execution error (JdbcSQLDataException) at org.h2.message.DbException/getJdbcSQLException (DbException.java:646).
      Invalid value "NULL" for parameter "result FETCH"; SQL statement:
      select 1 limit null [90008-214]
      
      dashboards=> (clojure.java.jdbc/query {:datasource
                                             (:data-source metabase.db.connection/*application-db*)}
                                            ["select 1 limit ?" nil])
      Execution error (JdbcSQLDataException) at org.h2.message.DbException/getJdbcSQLException (DbException.java:646).
      Invalid value "NULL" for parameter "result FETCH"; SQL statement:
      select 1 limit ? [90008-214]
      ```
      
      But with a normal repl, running the test does not error:
      
      ```clojure
      (deftest all-queries-test
        (mt/with-test-user :crowberto
          (with-temp-objects [objects]
            (premium-features-test/with-premium-features #{:audit-app}
                                   ;; limit to just the version
              (doseq [query-type #_(all-query-methods) [:metabase-enterprise.audit-app.pages.dashboards/most-popular-with-avg-speed]]
                (testing query-type
                  (do-tests-for-query-type query-type objects)))))))
      
      pages-test=> (clojure.test/run-test all-queries-test)
      
      Testing metabase-enterprise.audit-app.pages-test
      
      Ran 1 tests containing 1 assertions.
      0 failures, 0 errors.
      {:test 1, :pass 1, :fail 0, :error 0, :type :summary}
      ```
      
      And even more frustrating, just grabbing the sql and params and calling
      the same code:
      
      ```clojure
      common=> (let [driver (mdb/db-type)
                     sql check/sql
                     params check/params]
                 (with-open [conn (.getConnection mdb.connection/*application-db*)
                             stmt (doto (sql-jdbc.execute/prepared-statement driver conn sql params)
                                    foo
                                    )
                             rs   (sql-jdbc.execute/execute-prepared-statement! driver stmt)]
                   (into [] (clojure.java.jdbc/result-set-seq rs))))
      []
      ```
      
      I can get the test to fail by running the cloverage runner with a socket
      repl started and then running the test during that instrumented run:
      
      ```
      clojure -J"$(socket-repl 6000)" -X:dev:ee:ee-dev:test:cloverage
      ```
      
      But I'm not able to find anything interesting. It's a bug in CTEs with
      parameters in h2, and it seems that only this query is sensitive.
      
      If I inline the value it works under 2.1.214. And if I bump the version
      to 2.2.224 it works. So I'm bumping the version.
      
      * inline the offending value
      
      * Revert "Bump h2 to fix flaky test"
      
      This reverts commit 9cd6aed19cc4c143f79e611bb0c92218f18da365.
      Unverified
      fa764262
    • Case Nelson's avatar
      [MLv2] Handle coalesce type after conversion (#33814) · bf45689c
      Case Nelson authored
      
      * [MLv2] Handle coalesce type after conversion
      
      * Update test/metabase/lib/aggregation_test.cljc
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Only update fields on converted queries
      
      * Don't convert if base-type exists
      
      * Guard against non-numeric field ids
      
      * Fix test with hardcoded ids
      
      * Allow metadata/field to return nil on not found
      
      * Add ipaddress and mongobsonid types to equality-comparable-types
      
      * Support is-empty not-empty for mongobsonid
      
      * Add base-type to FE tests
      
      * Fix e2e tests - column metadata is valid with field types filled in
      
      ---------
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      Unverified
      bf45689c
    • Case Nelson's avatar
      [MLv2] Add function for database engine (#33942) · 1815233a
      Case Nelson authored
      
      * [MLv2] Add function for database engine
      
      * Update src/metabase/lib/js.cljs
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      
      * Use native query
      
      ---------
      
      Co-authored-by: default avatarmetamben <103100869+metamben@users.noreply.github.com>
      Unverified
      1815233a
    • Case Nelson's avatar
      [MLv2] Fix template-tags snippet-id (#33902) · d7de9380
      Case Nelson authored
      * [MLv2] Fix template-tags snippet-id
      
      Looking at this bug I found there were a couple problems that the
      converters were not properly handling. First, the conversion to js was
      copying snake case to kebab case instead of renaming. Second the conversion to
      clojure was not picking up kebab case keys but using the snake case keys.
      
      So I dropped the TemplateTag encoder and decoder and went forward with
      js->clj and clj->js since the only tricky part was keeping the tag names
      as strings and keeping the :type as keyword.
      
      * Address review comments
      Unverified
      d7de9380
    • Uladzimir Havenchyk's avatar
    • Uladzimir Havenchyk's avatar
    • Nemanja Glumac's avatar
      Fix archived items tooltip that's missing the item type (#33970) · ff0ab8bb
      Nemanja Glumac authored
      * Make archived item rely on the `model` for its type
      
      The `type` prop doesn't exist in the list of items.
      `models` on the other hand exists and it shows the underlying item model,
      which almost 1:1 matches the desired type.
      
      Almost, because we can questions "card" in the code.
      That will be accounted for in the next commit.
      
      * Handle `card` and `dataset` models
      
      Show "question` and "model" in the UI instead.
      
      * Move `getTranslatedEntityName` to the common utils
      
      * Use translated entities for the archived item tooltip
      
      * Switch back to the implicit return
      
      * Lowercase the translated model name
      
      * Add missing string translation
      
      * Add unit test for `getTranslatedEntityName`
      Unverified
      ff0ab8bb
    • Oisin Coveney's avatar
    • Cal Herries's avatar
    • Nemanja Glumac's avatar
      Nit: Fix typo in conditional table formatting (#34048) · 1865b068
      Nemanja Glumac authored
      'vice a versa' -> 'vice versa'
      Unverified
      1865b068
    • Ryan Laurie's avatar
    • Cal Herries's avatar
  4. Sep 21, 2023
  5. Sep 20, 2023
Loading