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

Aggregations on multiple fields showing datetimes as results with PostgreSQL? #2283

Closed
underyx opened this issue Mar 31, 2016 · 11 comments
Closed
Assignees
Labels
Type:Bug Product defects
Milestone

Comments

@underyx
Copy link

underyx commented Mar 31, 2016

  • I am using the Chrome browser.
  • My computer's OS is OS X El Capitan.
  • I'm running Metabase with the Docker image.
  • My database is PostgreSQL.
  • My Metabase version is 0.16.0.

Let's say I have the following data

CREATE TABLE sale (
    timestamp TIMESTAMP WITH TIME ZONE,
    region TEXT
);

I would like to get a line chart with time on the X axis, row count on the Y axis, and one line per region.

In the table view I'd expect this to be represented as one row per day and one column per region, with the cells containing the DB row counts. Here, it works perfectly with the included sample data:

But with PostgreSQL, I'm seeing this instead:

Oh dear! 🙈

@tlrobinson
Copy link
Contributor

Hmm I tried reproducing this on Postgres 9.4 with the schema and query you posted and a few data points:

insert into sale values (now() + '-1 day', 'foo'), (now() + '-1 day', 'bar'), (now() + '-2 days', 'foo');

and it seems to work fine:

screen shot 2016-03-31 at 3 53 34 pm

Did you change anything in the admin metadata page?

@agilliland
Copy link
Contributor

@tlrobinson what happens if the pivoting is flipped so that the timestamps end up as the smaller dimension?

@agilliland
Copy link
Contributor

in fact, it almost looks like we are parsing the cell value as a datetime in that scenario, instead of the header values.

@tlrobinson
Copy link
Contributor

@agilliland Yup, that did it:
screen shot 2016-03-31 at 3 59 32 pm

@tlrobinson
Copy link
Contributor

It seems like there are two things we should fix:

  1. We're not pivoting cols correctly.
  2. If there's a date/time column it should probably always use that as the row label.

@tlrobinson tlrobinson added this to the 0.16.1 milestone Mar 31, 2016
@tlrobinson tlrobinson self-assigned this Mar 31, 2016
@tlrobinson
Copy link
Contributor

I fixed # 1 in #2285. Do we also want to do # 2?

@agilliland
Copy link
Contributor

So 1) gets the value displaying properly and 2) formats the column header? if that's the case then i agree that we should do 2) as well.

@underyx
Copy link
Author

underyx commented Mar 31, 2016

Oh wow, I can't believe you guys were seriously this quick with the fix. You two are amazing! 😲

@salsakran
Copy link
Contributor

@underyx tell your friends ;)

@tlrobinson
Copy link
Contributor

@agilliland No, I meant # 1 fixes both of things you mentioned, # 2 would also put the date/time column in the first column (my first screenshot), as opposed to across the top (my second screenshot) regardless of the cardinality compared to the other column. Not sure if that's desired or not.

@agilliland
Copy link
Contributor

Ahh, yeah, lets skip that and we can decide a bit later if we think that's really the best thing to do. The fix in the current PR is all we need to close out this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type:Bug Product defects
Projects
None yet
Development

No branches or pull requests

4 participants