From f94916898a42d236e0d44ce60134829ad2e21336 Mon Sep 17 00:00:00 2001 From: yqkcn <410728991@qq.com> Date: Fri, 7 Apr 2023 19:18:00 +0800 Subject: [PATCH] simple code --- kylinpy/exceptions.py | 24 ----------------- kylinpy/service/kylin_service.py | 46 +++++--------------------------- 2 files changed, 7 insertions(+), 63 deletions(-) diff --git a/kylinpy/exceptions.py b/kylinpy/exceptions.py index e586ebe97..eb5a10150 100644 --- a/kylinpy/exceptions.py +++ b/kylinpy/exceptions.py @@ -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 """ diff --git a/kylinpy/service/kylin_service.py b/kylinpy/service/kylin_service.py index d3af84299..73e3f809b 100644 --- a/kylinpy/service/kylin_service.py +++ b/kylinpy/service/kylin_service.py @@ -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 @@ -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 = { @@ -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 = {