-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
[Datasources] Add: Add query runner for Yandex ClickHouse #1409
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, thanks! Few small things and we can merge this.
return schema.values() | ||
|
||
def _send_query(self, data, stream=False): | ||
url = 'http://{host}:{port}'.format(host=self.configuration['host'], port=self.configuration['port']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http and not https? why not let the user specify the full url instead of host/port pair?
return {'columns': columns, 'rows': result['data']} | ||
|
||
def run_query(self, query, user): | ||
logger.info("Clickhouse is about to execute query: %s", query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change this to logger.debug
.
q = self._clickhouse_query(query) | ||
data = json.dumps(q, cls=JSONEncoder) | ||
error = None | ||
except Exception as exc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we just return the exception as the error
value, we can let it bubble up and handle it there.
logger = logging.getLogger(__name__) | ||
|
||
try: | ||
import requests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to wrap this in try
/except
. requests
is a direct dependency of the project.
data = None | ||
error = str(exc) | ||
logging.exception(e) | ||
error = str(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, it's possible the exception might have some unicode characters, no? (like fragments of the query) So maybe better to use unicode
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
of course. changed.
Thanks! |
[Datasources] Add: Add query runner for Yandex ClickHouse
Query runner for this database: https://clickhouse.yandex
It works via HTTP interface and gets answer as JSON: https://clickhouse.yandex/reference_en.html#JSON