-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add dependency validations for DYNAMIC_TABLE, HYBRID_TABLE, TASK, VIEW
- Loading branch information
Showing
5 changed files
with
84 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from snowddl.blueprint import DynamicTableBlueprint | ||
from snowddl.validator.abc_validator import AbstractValidator | ||
|
||
|
||
class DynamicTableValidator(AbstractValidator): | ||
def get_blueprints(self): | ||
return self.config.get_blueprints_by_type(DynamicTableBlueprint) | ||
|
||
def validate_blueprint(self, bp: DynamicTableBlueprint): | ||
self._validate_depends_on(bp) | ||
|
||
def _validate_depends_on(self, bp: DynamicTableBlueprint): | ||
for depends_on_name in bp.depends_on: | ||
if depends_on_name == bp.full_name: | ||
raise ValueError(f"Dynamic table [{bp.full_name}] cannot depend on itself") | ||
|
||
if depends_on_name not in self.config.get_blueprints_by_type(DynamicTableBlueprint): | ||
raise ValueError(f"Dynamic table [{bp.full_name}] depends on another dynamic table " | ||
f"[{depends_on_name}] which does not exist in config") |
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,19 @@ | ||
from snowddl.blueprint import HybridTableBlueprint | ||
from snowddl.validator.abc_validator import AbstractValidator | ||
|
||
|
||
class HybridTableValidator(AbstractValidator): | ||
def get_blueprints(self): | ||
return self.config.get_blueprints_by_type(HybridTableBlueprint) | ||
|
||
def validate_blueprint(self, bp: HybridTableBlueprint): | ||
self._validate_depends_on(bp) | ||
|
||
def _validate_depends_on(self, bp: HybridTableBlueprint): | ||
for depends_on_name in bp.depends_on: | ||
if depends_on_name == bp.full_name: | ||
raise ValueError(f"Hybrid table [{bp.full_name}] cannot depend on itself") | ||
|
||
if depends_on_name not in self.config.get_blueprints_by_type(HybridTableBlueprint): | ||
raise ValueError(f"Hybrid table [{bp.full_name}] depends on another hybrid table " | ||
f"[{depends_on_name}] which does not exist in config") |
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,19 @@ | ||
from snowddl.blueprint import TaskBlueprint | ||
from snowddl.validator.abc_validator import AbstractValidator | ||
|
||
|
||
class TaskValidator(AbstractValidator): | ||
def get_blueprints(self): | ||
return self.config.get_blueprints_by_type(TaskBlueprint) | ||
|
||
def validate_blueprint(self, bp: TaskBlueprint): | ||
self._validate_depends_on(bp) | ||
|
||
def _validate_depends_on(self, bp: TaskBlueprint): | ||
for depends_on_name in bp.depends_on: | ||
if depends_on_name == bp.full_name: | ||
raise ValueError(f"Task [{bp.full_name}] cannot depend on itself") | ||
|
||
if depends_on_name not in self.config.get_blueprints_by_type(TaskBlueprint): | ||
raise ValueError(f"Task [{bp.full_name}] depends on another task " | ||
f"[{depends_on_name}] which does not exist in config") |
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,19 @@ | ||
from snowddl.blueprint import ViewBlueprint | ||
from snowddl.validator.abc_validator import AbstractValidator | ||
|
||
|
||
class ViewValidator(AbstractValidator): | ||
def get_blueprints(self): | ||
return self.config.get_blueprints_by_type(ViewBlueprint) | ||
|
||
def validate_blueprint(self, bp: ViewBlueprint): | ||
self._validate_depends_on(bp) | ||
|
||
def _validate_depends_on(self, bp: ViewBlueprint): | ||
for depends_on_name in bp.depends_on: | ||
if depends_on_name == bp.full_name: | ||
raise ValueError(f"View [{bp.full_name}] cannot depend on itself") | ||
|
||
if depends_on_name not in self.config.get_blueprints_by_type(ViewBlueprint): | ||
raise ValueError(f"View [{bp.full_name}] depends on another view " | ||
f"[{depends_on_name}] which does not exist in config") |