Skip to content

Commit

Permalink
Add query api
Browse files Browse the repository at this point in the history
  • Loading branch information
yqkcn committed Apr 7, 2023
1 parent 813b427 commit 00215c9
Showing 1 changed file with 34 additions and 0 deletions.
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

0 comments on commit 00215c9

Please sign in to comment.