Skip to content

Commit

Permalink
Reformat JSON schemas in parsers back to human-readable form, prevent…
Browse files Browse the repository at this point in the history
… black formatter from touching JSON schemas
  • Loading branch information
littleK0i committed Oct 13, 2023
1 parent f3ffba5 commit d9d52d1
Show file tree
Hide file tree
Showing 35 changed files with 1,005 additions and 280 deletions.
2 changes: 1 addition & 1 deletion snowddl/_config/sample02_01/__custom/01_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def handler(config: SnowDDLConfig):
# Add custom tables
for i in range(1,5):
for i in range(1, 5):
bp = TableBlueprint(
full_name=SchemaObjectIdent(config.env_prefix, "test_db", "test_schema", f"custom_table_{i}"),
columns=[
Expand Down
9 changes: 8 additions & 1 deletion snowddl/parser/account_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


account_params_json_schema = {"type": "object", "additionalProperties": {"type": ["boolean", "number", "string"]}}
# fmt: off
account_params_json_schema = {
"type": "object",
"additionalProperties": {
"type": ["boolean", "number", "string"]
}
}
# fmt: on


class AccountParameterParser(AbstractParser):
Expand Down
22 changes: 17 additions & 5 deletions snowddl/parser/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


# fmt: off
alert_json_schema = {
"type": "object",
"properties": {
"warehouse": {"type": "string"},
"schedule": {"type": "string"},
"condition": {"type": "string"},
"action": {"type": "string"},
"comment": {"type": "string"},
"warehouse": {
"type": "string"
},
"schedule": {
"type": "string"
},
"condition": {
"type": "string"
},
"action": {
"type": "string"
},
"comment": {
"type": "string"
},
},
"required": ["warehouse", "schedule", "condition", "action"],
"additionalProperties": False,
}
# fmt: on


class AlertParser(AbstractParser):
Expand Down
59 changes: 49 additions & 10 deletions snowddl/parser/business_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,61 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


# fmt: off
business_role_json_schema = {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"schema_owner": {"type": "array", "items": {"type": "string"}},
"schema_read": {"type": "array", "items": {"type": "string"}},
"schema_write": {"type": "array", "items": {"type": "string"}},
"warehouse_usage": {"type": "array", "items": {"type": "string"}},
"warehouse_monitor": {"type": "array", "items": {"type": "string"}},
"tech_roles": {"type": "array", "items": {"type": "string"}},
"global_roles": {"type": "array", "items": {"type": "string"}},
"comment": {"type": "string"},
},
},
"schema_owner": {
"type": "array",
"items": {
"type": "string"
}
},
"schema_read": {
"type": "array",
"items": {
"type": "string"
}
},
"schema_write": {
"type": "array",
"items": {
"type": "string"
}
},
"warehouse_usage": {
"type": "array",
"items": {
"type": "string"
}
},
"warehouse_monitor": {
"type": "array",
"items": {
"type": "string"
}
},
"tech_roles": {
"type": "array",
"items": {
"type": "string"
}
},
"global_roles": {
"type": "array",
"items": {
"type": "string"
}
},
"comment": {
"type": "string"
}
}
}
}
# fmt: on


class BusinessRoleParser(AbstractParser):
Expand Down
20 changes: 15 additions & 5 deletions snowddl/parser/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
from snowddl.parser.abc_parser import AbstractParser


# fmt: off
database_json_schema = {
"type": "object",
"properties": {
"is_transient": {"type": "boolean"},
"retention_time": {"type": "integer"},
"is_sandbox": {"type": "boolean"},
"comment": {"type": "string"},
"is_transient": {
"type": "boolean"
},
"retention_time": {
"type": "integer"
},
"is_sandbox": {
"type": "boolean"
},
"comment": {
"type": "string"
}
},
"additionalProperties": False,
"additionalProperties": False
}
# fmt: on


class DatabaseParser(AbstractParser):
Expand Down
24 changes: 19 additions & 5 deletions snowddl/parser/dynamic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


# fmt: off
dynamic_table_json_schema = {
"type": "object",
"properties": {
"text": {"type": "string"},
"target_lag": {"type": "string"},
"text": {
"type": "string"
},
"target_lag": {
"type": "string"
},
"warehouse": {
"type": "string",
},
"depends_on": {"type": "array", "items": {"type": "string"}, "minItems": 1},
"comment": {"type": "string"},
"depends_on": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
},
"comment": {
"type": "string"
},
},
"required": ["text", "target_lag", "warehouse"],
"additionalProperties": False,
"additionalProperties": False
}
# fmt: on


class DynamicTableParser(AbstractParser):
Expand Down
12 changes: 9 additions & 3 deletions snowddl/parser/event_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


# fmt: off
event_table_json_schema = {
"type": "object",
"properties": {
"change_tracking": {"type": "boolean"},
"comment": {"type": "string"},
"change_tracking": {
"type": "boolean"
},
"comment": {
"type": "string"
},
},
"additionalProperties": False,
"additionalProperties": False
}
# fmt: on


class EventTableParser(AbstractParser):
Expand Down
66 changes: 52 additions & 14 deletions snowddl/parser/external_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,67 @@
from snowddl.parser.abc_parser import AbstractParser, ParsedFile


# fmt: off
external_function_json_schema = {
"type": "object",
"properties": {
"arguments": {"type": "object", "additionalProperties": {"type": "string"}},
"returns": {"type": "string"},
"api_integration": {"type": "string"},
"arguments": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"returns": {
"type": "string"
},
"api_integration": {
"type": "string"
},
"url": {
"type": "string",
},
"is_secure": {"type": "boolean"},
"is_strict": {"type": "boolean"},
"is_immutable": {"type": "boolean"},
"headers": {"type": "object", "additionalProperties": {"type": "string"}},
"context_headers": {"type": "array", "items": {"type": "string"}, "minItems": 1},
"max_batch_rows": {"type": "integer"},
"compression": {"type": "string"},
"request_translator": {"type": "string"},
"response_translator": {"type": "string"},
"comment": {"type": "string"},
"is_secure": {
"type": "boolean"
},
"is_strict": {
"type": "boolean"
},
"is_immutable": {
"type": "boolean"
},
"headers": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"context_headers": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
},
"max_batch_rows": {
"type": "integer"
},
"compression": {
"type": "string"
},
"request_translator": {
"type": "string"
},
"response_translator": {
"type": "string"
},
"comment": {
"type": "string"
}
},
"required": ["api_integration", "url"],
"additionalProperties": False,
"additionalProperties": False
}
# fmt: on


class ExternalFunctionParser(AbstractParser):
Expand Down
Loading

0 comments on commit d9d52d1

Please sign in to comment.