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

[Datasources] Add: Add query runner for Yandex ClickHouse #1409

Merged
merged 5 commits into from
Nov 24, 2016
Merged

[Datasources] Add: Add query runner for Yandex ClickHouse #1409

merged 5 commits into from
Nov 24, 2016

Conversation

denisov-vlad
Copy link
Member

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

Copy link
Member

@arikfr arikfr left a 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'])
Copy link
Member

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)
Copy link
Member

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:
Copy link
Member

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
Copy link
Member

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.

@arikfr arikfr changed the title clickhouse: query runner for Yandex.Clickhouse DB Add: [Datasources] Add query runner for Yandex ClickHouse Nov 22, 2016
data = None
error = str(exc)
logging.exception(e)
error = str(e)
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course. changed.

@arikfr arikfr changed the title Add: [Datasources] Add query runner for Yandex ClickHouse [Datasources] Add: Add query runner for Yandex ClickHouse Nov 24, 2016
@arikfr arikfr merged commit 9b6b27a into getredash:master Nov 24, 2016
@arikfr
Copy link
Member

arikfr commented Nov 24, 2016

Thanks!

dairyo pushed a commit to KiiCorp/redash that referenced this pull request Mar 1, 2019
[Datasources] Add: Add query runner for Yandex ClickHouse
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

Successfully merging this pull request may close these issues.

2 participants