metabase icon indicating copy to clipboard operation
metabase copied to clipboard

Trend Visualization fails with query editor's generated native query

Open calsoftwaresolutions opened this issue 2 years ago • 1 comments

Describe the bug I used the Query Editor to create a mongodb question to visualize a trend. It works as expected in the Query Editor however when I convert it to Native Query and execute the generated query, the Trend visualization fails with this message "Group by a time field to see how this has changed over time".

Logs No errors in logs.

To Reproduce Steps to reproduce the behavior:

  1. Select a MongoBD database
  2. Select Database table
  3. Filter, summarize and select a date group field
  4. Sort and limit by 2
  5. Visualize as Trend. This works
  6. View native query
  7. Convert this question to native query
  8. Select database table
  9. Run query
  10. Trend visualization fails to display and is disabled in the list of visualizations. Error message, "Group by a time field to see how this has changed over time".

Expected behavior I expected the native query to work as it did using the Query Editor since the editor generated the query.

Screenshots 2022-09-20_7-39-01

Information about your Metabase Installation: { "browser-info": { "language": "en-US", "platform": "Linux x86_64", "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36", "vendor": "Google Inc." }, "system-info": { "file.encoding": "UTF-8", "java.runtime.name": "OpenJDK Runtime Environment", "java.runtime.version": "11.0.16.1+1", "java.vendor": "Eclipse Adoptium", "java.vendor.url": "https://adoptium.net/", "java.version": "11.0.16.1", "java.vm.name": "OpenJDK 64-Bit Server VM", "java.vm.version": "11.0.16.1+1", "os.name": "Linux", "os.version": "5.19.0-76051900-generic", "user.language": "en", "user.timezone": "GMT" }, "metabase-info": { "databases": [ "h2", "mongo" ], "hosting-env": "unknown", "application-database": "mysql", "application-database-details": { "database": { "name": "MySQL", "version": "8.0.28" }, "jdbc-driver": { "name": "MariaDB Connector/J", "version": "2.7.6" } }, "run-mode": "prod", "version": { "date": "2022-09-02", "tag": "v0.44.3", "branch": "release-x.44.x", "hash": "7d50282" }, "settings": { "report-timezone": "America/Barbados" } } }

Severity This issue is sever as I'm unable to find a work around and cannot use a refined mongodb query to display the trend.

Additional context I'm running metabase from a docker container.

calsoftwaresolutions avatar Sep 20 '22 12:09 calsoftwaresolutions

mongo_generated_query.txt

This is the generated query.

calsoftwaresolutions avatar Sep 20 '22 13:09 calsoftwaresolutions

This may be the same issue as #13208

camsaul avatar Dec 14 '22 20:12 camsaul

Similar problem here. We just upgraded from an old version of MB (0.32 to 0.46). Trends based on native MongoDB queries used to work without problems on 0.32. After the upgrade, we have the "Group by a time field to see how this has changed over time" message on the same queries (no changes).

What's disturbing is that the field is recognised as a date field. image

streusi138 avatar Apr 14 '23 12:04 streusi138

I suspect this is fixed. Here's a loom trying to recreate and I can't seem to do it. I'm wondering if https://github.com/metabase/metabase/issues/13208 resolved it.

markbastian avatar Oct 26 '23 17:10 markbastian

@markbastian have you tried reproducing it on 44 or 45?

darksciencebase avatar Dec 11 '23 12:12 darksciencebase

Repro on v0.45.4. I'm going to try again on v1.48.2.

markbastian avatar Jan 09 '24 16:01 markbastian

I am able to reproduce this on v1.48.2 as shown here.

markbastian avatar Jan 09 '24 16:01 markbastian