Skip to content

Commit

Permalink
add Error
Browse files Browse the repository at this point in the history
  • Loading branch information
yqkcn committed Apr 7, 2023
1 parent c51d817 commit 02908e4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
24 changes: 24 additions & 0 deletions kylinpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,30 @@ 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
15 changes: 8 additions & 7 deletions kylinpy/service/kylin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from __future__ import unicode_literals

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


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

return response

Expand All @@ -140,39 +141,39 @@ def create_saved_queries(self, sql, name, desc=None, **kwargs):
try:
response = self.client.post('/saved_queries', **kwargs).json()
except InternalServerError as err:
raise KylinQueryError(err)
raise KylinCreateSavedQueryError(err)

return response

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

return response

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

return response

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

return response

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

return response

Expand Down

0 comments on commit 02908e4

Please sign in to comment.