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

'DruidDatasource' object has no attribute 'database' #207

Closed
x4base opened this issue Mar 29, 2016 · 8 comments
Closed

'DruidDatasource' object has no attribute 'database' #207

x4base opened this issue Mar 29, 2016 · 8 comments

Comments

@x4base
Copy link
Contributor

x4base commented Mar 29, 2016

In http://localhost:8088/caravel/explore/druid/1/

Traceback (most recent call last):
  File "/projects/druid/panoramix_test/caravel/views.py", line 445, in explore
    payload = obj.get_json()
  File "/projects/druid/panoramix_test/caravel/viz.py", line 236, in get_json
    cache_timeout = self.cache_timeout
  File "/projects/druid/panoramix_test/caravel/viz.py", line 222, in cache_timeout
    self.datasource.database.cache_timeout or
AttributeError: 'DruidDatasource' object has no attribute 'database'
@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

+1

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

"GET /caravel/explore/druid/2/?viz_type=table&granularity=one+day&since=7+days+ago&until=1+day+ago&row_limit=5000&include_search=false&metrics=count&flt_col_0=country_woeid&flt_op_0=in&flt_eq_0=&slice_id=&slice_name=&collapsed_fieldsets=&action=&datasource_name=fact_supply_xd&datasource_id=2&datasource_type=druid&previous_viz_type=table&json=true&force=true HTTP/1.1" 500 -

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

Ok found the fix but still trying to figure out the issue
the fix is this - when you refresh metadata, the data source you are querying against needs to have cache timeout in the settings in the UI.
If the field is left blank - then we get an error : i.e AttributeError: 'DruidDatasource' object has no attribute 'database'
I even included the field in caravel_config.py like CACHE_DEFAULT_TIMEOUT=6000 but that didn't help either. The UI needs to have that field otherwise we get an exception here:
https://github.com/airbnb/caravel/blob/master/caravel/viz.py#L225
the code goes into this if else condition (when the field is left blank): https://github.com/airbnb/caravel/blob/master/caravel/viz.py#L235

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

@mistercrunch I fixed the issue. I will send the PR asap

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

#210

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

Stack Trace:

Traceback (most recent call last):
File "/home/y/lib/python2.7/site-packages/caravel/views.py", line 446, in explore
payload = obj.get_json()
File "/home/y/lib/python2.7/site-packages/caravel/viz.py", line 270, in get_json
cache.set(cache_key, payload, timeout=self.cache_timeout)
File "/home/y/lib/python2.7/site-packages/caravel/viz.py", line 223, in cache_timeout
self.datasource.database.cache_timeout or
AttributeError: 'DruidDatasource' object has no attribute 'database'
2016-03-29 20:42:21,432:INFO:werkzeug:66.228.162.48 - - [29/Mar/2016 20:42:21] "GET /caravel/explore/druid/2/?viz_type=table&granularity=one+day&since=7+days+ago&until=now&row_limit=5000&include_search=false&metrics=count&flt_col_0=country_woeid&flt_op_0=in&flt_eq_0=&slice_id=&slice_name=&collapsed_fieldsets=&action=&datasource_name=fact_supply_xd&datasource_id=2&datasource_type=druid&previous_viz_type=table&json=true&force=true HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/y/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "/home/y/lib/python2.7/site-packages/flask_appbuilder/security/decorators.py", line 26, in wraps
return f(self, _args, *_kwargs)
File "/home/y/lib/python2.7/site-packages/caravel/models.py", line 1113, in wrapper
return f(_args, *_kwargs)
File "/home/y/lib/python2.7/site-packages/caravel/views.py", line 451, in explore
raise e
AttributeError: 'DruidDatasource' object has no attribute 'database'

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2016

obj.get_json() throws an exception if cache timeout is not specified in the UI

@mistercrunch
Copy link
Member

This is now fixed in master please confirm

graceguo-supercat pushed a commit to graceguo-supercat/superset that referenced this issue Oct 4, 2021
* feat: add more util functions

* feat: add unit test

* feat: define HasToString

* fix: unit test

* fix: update unit tests

* feat: add scale types

* feat: update scale parsing

* fix: enum

* feat: add color scale extraction

* refactor: create scale from config

* feat: parse more scales and add more test

* feat: add tests for band and point

* test: add more unit tests

* refactor: separate applyXXX into multiple files

* feat: parse nice time

* test: add unit tests

* test: make 100% coverage

* fix: complete coverage

* refactor: update type definitions

* fix: address comments

* fix: add comments for date parts

* fix: build issue

* fix: broken tests
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 17, 2021
* feat: add more util functions

* feat: add unit test

* feat: define HasToString

* fix: unit test

* fix: update unit tests

* feat: add scale types

* feat: update scale parsing

* fix: enum

* feat: add color scale extraction

* refactor: create scale from config

* feat: parse more scales and add more test

* feat: add tests for band and point

* test: add more unit tests

* refactor: separate applyXXX into multiple files

* feat: parse nice time

* test: add unit tests

* test: make 100% coverage

* fix: complete coverage

* refactor: update type definitions

* fix: address comments

* fix: add comments for date parts

* fix: build issue

* fix: broken tests
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 24, 2021
* feat: add more util functions

* feat: add unit test

* feat: define HasToString

* fix: unit test

* fix: update unit tests

* feat: add scale types

* feat: update scale parsing

* fix: enum

* feat: add color scale extraction

* refactor: create scale from config

* feat: parse more scales and add more test

* feat: add tests for band and point

* test: add more unit tests

* refactor: separate applyXXX into multiple files

* feat: parse nice time

* test: add unit tests

* test: make 100% coverage

* fix: complete coverage

* refactor: update type definitions

* fix: address comments

* fix: add comments for date parts

* fix: build issue

* fix: broken tests
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 25, 2021
* feat: add more util functions

* feat: add unit test

* feat: define HasToString

* fix: unit test

* fix: update unit tests

* feat: add scale types

* feat: update scale parsing

* fix: enum

* feat: add color scale extraction

* refactor: create scale from config

* feat: parse more scales and add more test

* feat: add tests for band and point

* test: add more unit tests

* refactor: separate applyXXX into multiple files

* feat: parse nice time

* test: add unit tests

* test: make 100% coverage

* fix: complete coverage

* refactor: update type definitions

* fix: address comments

* fix: add comments for date parts

* fix: build issue

* fix: broken tests
zhaoyongjie pushed a commit to zhaoyongjie/incubator-superset that referenced this issue Nov 26, 2021
* feat: add more util functions

* feat: add unit test

* feat: define HasToString

* fix: unit test

* fix: update unit tests

* feat: add scale types

* feat: update scale parsing

* fix: enum

* feat: add color scale extraction

* refactor: create scale from config

* feat: parse more scales and add more test

* feat: add tests for band and point

* test: add more unit tests

* refactor: separate applyXXX into multiple files

* feat: parse nice time

* test: add unit tests

* test: make 100% coverage

* fix: complete coverage

* refactor: update type definitions

* fix: address comments

* fix: add comments for date parts

* fix: build issue

* fix: broken tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants