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

Cannot display Time Series Line Chart #4770

Closed
3 tasks done
syzuhdi opened this issue Apr 6, 2018 · 9 comments
Closed
3 tasks done

Cannot display Time Series Line Chart #4770

syzuhdi opened this issue Apr 6, 2018 · 9 comments
Labels
inactive Inactive for >= 30 days

Comments

@syzuhdi
Copy link

syzuhdi commented Apr 6, 2018

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if any
  • I have reproduced the issue with at least the latest released version of superset
  • I have checked the issue tracker for the same issue and I haven't found one similar

Superset version

0.22.1

Expected results

Data shown in Time series Line Chart

Actual results

image

When I click Run Query button in Slices, an error occur.
Error u'CITY'

Traceback (most recent call last):
File "/usr/local/venv/lib/python2.7/site-packages/superset/viz.py", line 278, in get_payload
data = self.get_data(df)
File "/usr/local/venv/lib/python2.7/site-packages/superset/viz.py", line 1045, in get_data
df = self.process_data(df)
File "/usr/local/venv/lib/python2.7/site-packages/superset/viz.py", line 981, in process_data
values=fd.get('metrics'))
File "/usr/local/venv/lib/python2.7/site-packages/pandas/core/reshape/pivot.py", line 135, in pivot_table
grouped = data.groupby(keys)
File "/usr/local/venv/lib/python2.7/site-packages/pandas/core/generic.py", line 4416, in groupby
**kwargs)
File "/usr/local/venv/lib/python2.7/site-packages/pandas/core/groupby.py", line 1699, in groupby
return klass(obj, by, **kwds)
File "/usr/local/venv/lib/python2.7/site-packages/pandas/core/groupby.py", line 392, in init
mutated=self.mutated)
File "/usr/local/venv/lib/python2.7/site-packages/pandas/core/groupby.py", line 2690, in _get_grouper
raise KeyError(gpr)
KeyError: u'CITY'

And this is the QUERY

SELECT "CITY",
"timestamp",
"count_QTY"
FROM
(SELECT "CITY" AS "CITY",
"REGN_DATE" AS "timestamp",
count(VIN_NO) AS "count_QTY"
FROM
(SELECT *
FROM mycrm_registration) expr_qry
JOIN
(SELECT "CITY",
mme_inner

FROM
(SELECT "CITY" AS "CITY__",
count(VIN_NO) AS mme_inner__
FROM
(SELECT *
FROM mycrm_registration) expr_qry
WHERE "REGN_DATE" >= TO_TIMESTAMP('2018-03-30T00:00:00', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')
AND "REGN_DATE" <= TO_TIMESTAMP('2018-04-06T08:20:13', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')
GROUP BY "CITY"
ORDER BY count(VIN_NO) DESC)
WHERE ROWNUM <= 100) anon_1 ON "CITY" = "CITY__"
WHERE "REGN_DATE" >= TO_TIMESTAMP('2018-03-30T00:00:00', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')
AND "REGN_DATE" <= TO_TIMESTAMP('2018-04-06T08:20:13', 'YYYY-MM-DD"T"HH24:MI:SS.ff6')
GROUP BY "CITY",
"REGN_DATE"
ORDER BY count(VIN_NO) DESC)
WHERE ROWNUM <= 50000

Any idea?

Steps to reproduce

@mistercrunch
Copy link
Member

mistercrunch commented Apr 6, 2018

Can you try on 0.24.0?

@jhettler
Copy link

jhettler commented Apr 6, 2018

Hi, I have found the similar issue yesterday on 0.24.0. And it is not a problem only in Time Series Line Chart, I was able to reproduce it with Pie Chart and Histogram as well, I didn't try more visualizations.

In my case, we use Snowflake database and I expected it is related to DB engine and I am still not sure what's exactly wrong, everything works fine with Superset examples and as well if I add the tables from Snowflake straight from dialog Sources/Tables/Add table (plus icon in right upper corner). But if I try to create datasource/table from query it didn't work. Then I realize there are quotes around column names in query (view query menu in graph view - upper right corner).

Same as in @syzuhdi case

SELECT "CITY",
"timestamp",
"count_QTY"

I tried to lowercase all column names and whoila, everything works. Lowercased name of columns are not in doublequotes and it is correctly interpreted.

I made following steps:

  1. Run a query in SQL lab
  2. Visualize it - it will ask for datasource name
  3. Save the visualization
  4. Go to Sources/Tables and edit the table/datasource you created in step 2
  5. Rename all columns to lowercase
  6. Try to visualize graph

It's not nice, but it works for us as a temporary workaround.
HTH.

@syzuhdi
Copy link
Author

syzuhdi commented Apr 6, 2018

Thank you @jhettler. It works for us.

@mistercrunch
Copy link
Member

This may help these issues:
#4724

@villebro
Copy link
Member

villebro commented Apr 28, 2018

I am also facing the same issue with Snowflake. I tracked it down to process_data in viz.py
https://github.com/apache/incubator-superset/blob/caa72675a5b69e0ba133a3e652e1f807e0163d9c/superset/viz.py#L1104-L1107, where fd.get('groupby') are uppercase, but the corresponding Series in df are lowercase. I was also able to confirm that the @jhettler hack works in my case. A simple fix in this case would be to lowercase the groupby columns, but not sure if that is ok under all circumstances. Any alternative suggestions?

@villebro
Copy link
Member

villebro commented Apr 29, 2018

This bug is the same as #4662, where an alternative solution is outlined.

@stale
Copy link

stale bot commented Apr 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 10, 2019
@villebro
Copy link
Member

@syzuhdi this issue has been resolved and can be closed

@stale stale bot removed the inactive Inactive for >= 30 days label Apr 11, 2019
@stale
Copy link

stale bot commented Jun 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Jun 10, 2019
@stale stale bot closed this as completed Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

4 participants