Skip to content

Commit

Permalink
simple code
Browse files Browse the repository at this point in the history
  • Loading branch information
yqkcn committed Apr 7, 2023
1 parent 0e9b919 commit f949168
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 63 deletions.
24 changes: 0 additions & 24 deletions kylinpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,6 @@ class KylinQueryError(KylinError):
""" Raise when Kylin query error """


class KylinQueryPrestateError(KylinError):
""" Raise when Kylin query prestate error """


class KylinCreateSavedQueryError(KylinError):
""" Raise when Kylin create saved query error """


class KylinRemoveSavedQueryError(KylinError):
""" Raise when Kylin remove saved query error """


class KylinGetSavedQueryError(KylinError):
""" Raise when Kylin get saved query error """


class KylinGetRunningQueryError(KylinError):
""" Raise when Kylin get running query error """


class KylinStopQueryError(KylinError):
""" Raise when Kylin stop query error """


class KylinUnsupportedType(KylinError):
""" Raise when unsupport type in Kylin """

Expand Down
46 changes: 7 additions & 39 deletions kylinpy/service/kylin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
from __future__ import unicode_literals

from kylinpy.client import InternalServerError, UnauthorizedError
from kylinpy.exceptions import KylinQueryError, KylinCubeError, KylinJobError, KylinQueryPrestateError, \
KylinCreateSavedQueryError, KylinRemoveSavedQueryError, KylinGetSavedQueryError, KylinGetRunningQueryError,\
KylinStopQueryError
from kylinpy.exceptions import KylinQueryError, KylinCubeError, KylinJobError
from ._service_interface import ServiceInterface


Expand Down Expand Up @@ -124,12 +122,7 @@ def query_prestate(self, sql, limit=0, offset=50000, acceptPartial=False, **kwar
'sql': sql,
}
kwargs.setdefault('json', json_data)
try:
response = self.client.post('/query/prestate', **kwargs).json()
except InternalServerError as err:
raise KylinQueryPrestateError(err)

return response
return self.client.post('/query/prestate', **kwargs).json()

def create_saved_queries(self, sql, name, desc=None, **kwargs):
json_data = {
Expand All @@ -139,44 +132,19 @@ def create_saved_queries(self, sql, name, desc=None, **kwargs):
'description': desc,
}
kwargs.setdefault('json', json_data)
try:
response = self.client.post('/saved_queries', **kwargs).json()
except InternalServerError as err:
raise KylinCreateSavedQueryError(err)

return response
return self.client.post('/saved_queries', **kwargs).json()

def remove_saved_query(self, query_id):
try:
response = self.client.delete('/saved_queries/{}'.format(query_id)).json()
except InternalServerError as err:
raise KylinRemoveSavedQueryError(err)

return response
return self.client.delete('/saved_queries/{}'.format(query_id)).json()

def get_saved_queries(self):
try:
response = self.client.get('/saved_queries').json()
except InternalServerError as err:
raise KylinGetSavedQueryError(err)

return response
return self.client.get('/saved_queries').json()

def get_running_queries(self):
try:
response = self.client.get('/query/runningQueries').json()
except InternalServerError as err:
raise KylinGetRunningQueryError(err)

return response
return self.client.get('/query/runningQueries').json()

def stop_query(self, query_id):
try:
response = self.client.get('/query/{}/stop'.format(query_id)).json()
except InternalServerError as err:
raise KylinStopQueryError(err)

return response
return self.client.get('/query/{}/stop'.format(query_id)).json()

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

0 comments on commit f949168

Please sign in to comment.