From c99fd5ccb3d0db9f02f5b468d8e227302442e192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=BE=B0?= Date: Mon, 9 Jan 2023 19:41:15 +0800 Subject: [PATCH] Source model fix --- registry/sql-registry/registry/models.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/registry/sql-registry/registry/models.py b/registry/sql-registry/registry/models.py index f032099af..56160a05d 100644 --- a/registry/sql-registry/registry/models.py +++ b/registry/sql-registry/registry/models.py @@ -1,6 +1,6 @@ from abc import ABC, abstractmethod from enum import Enum -from typing import Optional, Union +from typing import Any, Dict, Optional, Union from uuid import UUID import json import re @@ -417,15 +417,15 @@ def __init__(self, qualified_name: str, name: str, type: str, - path: str, preprocessing: Optional[str] = None, event_timestamp_column: Optional[str] = None, timestamp_format: Optional[str] = None, - tags: dict = {}): + tags: dict = {}, + **options: Dict[str, Any]): self.qualified_name = qualified_name self.name = name self.type = type - self.path = path + self.options = options self.preprocessing = preprocessing self.event_timestamp_column = event_timestamp_column self.timestamp_format = timestamp_format @@ -436,13 +436,13 @@ def entity_type(self) -> EntityType: return EntityType.Source def to_dict(self) -> dict: - ret = { + ret = self.options.copy() + ret = {**ret, **{ "qualifiedName": self.qualified_name, "name": self.name, "type": self.type, - "path": self.path, "tags": self.tags, - } + }} if self.preprocessing is not None: ret["preprocessing"] = self.preprocessing if self.event_timestamp_column is not None: @@ -674,16 +674,16 @@ def to_attr(self) -> ProjectAttributes: class SourceDef: def __init__(self, name: str, - path: str, type: str, qualified_name: str = "", preprocessing: Optional[str] = None, event_timestamp_column: Optional[str] = None, timestamp_format: Optional[str] = None, - tags: dict = {}): + tags: dict = {}, + **options: Dict[str, Any]): self.qualified_name = qualified_name self.name = name - self.path = path + self.options = options self.type = type self.preprocessing = preprocessing self.event_timestamp_column = event_timestamp_column @@ -694,11 +694,11 @@ def to_attr(self) -> SourceAttributes: return SourceAttributes(qualified_name=self.qualified_name, name=self.name, type=self.type, - path=self.path, preprocessing=self.preprocessing, event_timestamp_column=self.event_timestamp_column, timestamp_format=self.timestamp_format, - tags=self.tags) + tags=self.tags, + **self.options) class AnchorDef: def __init__(self,