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

This issue doesn't let download answers using sql templates #4540

Closed
riser101 opened this issue Mar 17, 2017 · 5 comments
Closed

This issue doesn't let download answers using sql templates #4540

riser101 opened this issue Mar 17, 2017 · 5 comments
Labels
Querying/Native The SQL/native query editor Querying/Parameters & Variables Filter widgets, field filters, variables etc. .Unable to Reproduce

Comments

@riser101
Copy link

riser101 commented Mar 17, 2017

Bugs

  • Your browser and the version: Google Chrome, Version 56.0.2924.87 (64-bit)
  • Your operating system: OS X El Capitan, version 10.11.4 (15E65)
  • Your databases: mysql
  • Metabase version: v0.22.2
  • Metabase hosting environment: Debian GNU/Linux 8.6 (jessie)
  • Metabase internal database: H2 default

Bug Description :
This issue is with to sql templates. When you create a template it's not compulsory to define a default value. You've a required switch. When this switch is turned off (by default it's turned off), the variable value in the sql template is set to null. Now, when we load the sql template page in question for the first time, it fires the query with the variable as null and throws an error java.lang.NullPointerException. Also, if you then enter a value in the filter widget and hit get answer button, you get the query results but can't download the results. It throws the same error : java.lang.NullPointerException.

This error is not very self explanatory to business users and I believe you're targeting business.

The solution to this problem I believe is either don't fire the query on the sql templates page on it's first load or make default values compulsory.

  • Repeatable steps to reproduce the issue
  1. Create a question by hitting New Question on metabase's hompage.
  2. Switch to sql mode.
  3. Write an sql query with at least one variable and do not turn on required flag for this variable.
  4. Choose variable type as Number and save the question.
  5. Go to metabase's homepage
  6. Click questions
  7. Click on your question that you just created in the above steps.
  8. You'll see this error java.lang.NullPointerException
  9. Now enter a value for your variable in the filter widget and hit get answer.
  10. You'll get result table but when you hit the download button, you'll again see java.lang.NullPointerException and won't be able to download the answer.
@salsakran salsakran added Enhancement Querying/Parameters & Variables Filter widgets, field filters, variables etc. Querying/Native The SQL/native query editor labels Mar 20, 2017
@salsakran
Copy link
Contributor

For situations like this, you should probably wrap the variable with [[ and ]] and make sure the template works with any set of user entered (or lack thereof) parameters.

Agreed we should have a more specific error message, however.

@riser101
Copy link
Author

riser101 commented Mar 21, 2017

How can a query with variables work when the variable isn't assigned a value?

Agreed we should have a more specific error message, however.

Yes, we should.

@milgner
Copy link

milgner commented May 15, 2017

Maybe related: I have a SQL query with optional parameters which shows the table data without problems. The variables are wrapped in [[ and ]] and there are no errors shown anywhere, yet the download button is missing. This was working with v0.23 but the button disappeared after upgrading to v0.24.
Other queries remain downloadable.
If you think this is not related, I'll open a separate issue, but I didn't want to spam your tracker ;)

@attekei
Copy link
Contributor

attekei commented May 15, 2017

Hi @milgner! The issue you found might be a duplicate of #5047 which I fixed in #5099. That will be included in our next minor release (0.24.2).

@walterl
Copy link
Contributor

walterl commented Mar 12, 2020

I can't reproduce this issue on the current master. Closing this since it was probably fixed along the way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Querying/Native The SQL/native query editor Querying/Parameters & Variables Filter widgets, field filters, variables etc. .Unable to Reproduce
Projects
None yet
Development

No branches or pull requests

6 participants