-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor validation decorators (#1354)
* Refactor validation decorators
- Loading branch information
Showing
7 changed files
with
104 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
querybook/server/lib/query_analysis/validation/decorators/base_validation_decorator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from abc import ABCMeta, abstractmethod | ||
from typing import List | ||
|
||
from lib.query_analysis.validation.base_query_validator import ( | ||
QueryValidationResult, | ||
) | ||
from lib.query_analysis.validation.base_query_validator import BaseQueryValidator | ||
|
||
|
||
class BaseValidationDecorator(metaclass=ABCMeta): | ||
def __init__(self, validator: BaseQueryValidator): | ||
self._validator = validator | ||
|
||
@abstractmethod | ||
def decorate_validation_results( | ||
self, | ||
validation_results: List[QueryValidationResult], | ||
query: str, | ||
uid: int, | ||
engine_id: int, | ||
**kwargs, | ||
) -> List[QueryValidationResult]: | ||
raise NotImplementedError() | ||
|
||
def validate( | ||
self, | ||
query: str, | ||
uid: int, | ||
engine_id: int, | ||
**kwargs, | ||
) -> List[QueryValidationResult]: | ||
validation_results = self._validator.validate(query, uid, engine_id, **kwargs) | ||
return self.decorate_validation_results( | ||
validation_results, query, uid, engine_id, **kwargs | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.