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

FEAT: Add some Apache Kylin query api #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions kylinpy/service/kylin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,40 @@ def query(self, sql, limit=50000, offset=0, acceptPartial=False, **kwargs):

return response

def query_prestate(self, sql, limit=0, offset=50000, acceptPartial=False, **kwargs):
"""https://cwiki.apache.org/confluence/display/KYLIN/Query+API"""
json_data = {
'acceptPartial': acceptPartial,
'limit': limit,
'offset': offset,
'project': self.project,
'sql': sql,
}
kwargs.setdefault('json', json_data)
return self.client.post('/query/prestate', **kwargs).json()

def create_saved_queries(self, sql, name, desc=None, **kwargs):
json_data = {
'sql': sql,
'name': name,
'project': self.project,
'description': desc,
}
kwargs.setdefault('json', json_data)
return self.client.post('/saved_queries', **kwargs).json()

def remove_saved_query(self, query_id):
return self.client.delete('/saved_queries/{}'.format(query_id)).json()

def get_saved_queries(self):
return self.client.get('/saved_queries').json()

def get_running_queries(self):
return self.client.get('/query/runningQueries').json()

def stop_query(self, query_id):
return self.client.get('/query/{}/stop'.format(query_id)).json()

def projects(self, **kwargs):
params = {
'pageOffset': 0,
Expand Down