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

[api/v1][query_obj] add default prequeries array #7039

Merged
merged 2 commits into from Mar 15, 2019

Conversation

williaster
Copy link
Contributor

@williaster williaster commented Mar 15, 2019

This PR only affects the embeddable charts /api/v1/query endpoint. I'm working on adding react <ChartDataProvider /> components in @superset-ui and when I use the new (non-legacy) WordCloudPlugin together with SuperChart + ChartClient I get the following stack trace from Python in the Superset App:

POST /api/v1/query/ => {"datasource":{"id":3,"type":"table"},"queries":[{"granularity":"ds","metrics":[{"label":"sum__num"}],"groupby":["name"]}]}

2019-03-14 17:24:21,854:ERROR:root:'NoneType' object has no attribute 'append'
Traceback (most recent call last):
  File "/Users/chris_williams/dev/superset/superset/common/query_context.py", line 206, in get_df_payload
    query_result = self.get_query_result(query_obj)
  File "/Users/chris_williams/dev/superset/superset/common/query_context.py", line 82, in get_query_result
    result = self.datasource.query(query_object.to_dict())
  File "/Users/chris_williams/dev/superset/superset/connectors/sqla/models.py", line 861, in query
    query_obj['prequeries'].append(sql)

This is because prequeries is not passed for this chart, and there is no default on the Python side. This PR adds a default and updates the type, I think it's an optional List of Dicts, setting the default to {} errored downstream as something was trying to append to it 😄 so maybe it was typed wrong?

@xtinec @conglei @kristw

@conglei
Copy link
Contributor

conglei commented Mar 15, 2019

Thanks for fixing this!

@codecov-io
Copy link

Codecov Report

Merging #7039 into master will not change coverage.
The diff coverage is 0%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #7039   +/-   ##
=======================================
  Coverage   64.45%   64.45%           
=======================================
  Files         421      421           
  Lines       20524    20524           
  Branches     2245     2245           
=======================================
  Hits        13229    13229           
  Misses       7168     7168           
  Partials      127      127
Impacted Files Coverage Δ
superset/common/query_object.py 26.31% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ca2cc1...1931911. Read the comment docs.

@williaster williaster merged commit 7d7210d into apache:master Mar 15, 2019
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants