-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addded creator() and updater() for table_partition
- Loading branch information
1 parent
bcb1371
commit 5ee9002
Showing
3 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
pyatlan/generator/templates/methods/asset/table_partition.jinja2
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,69 @@ | ||
|
||
@overload | ||
@classmethod | ||
def creator( | ||
cls, | ||
*, | ||
name: str, | ||
table_qualified_name: str, | ||
) -> TablePartition: ... | ||
|
||
@overload | ||
@classmethod | ||
def creator( | ||
cls, | ||
*, | ||
name: str, | ||
connection_qualified_name: str, | ||
database_name: str, | ||
database_qualified_name: str, | ||
schema_name: str, | ||
schema_qualified_name: str, | ||
table_name: str, | ||
table_qualified_name: str, | ||
) -> TablePartition: ... | ||
|
||
@classmethod | ||
@init_guid | ||
def creator( | ||
cls, | ||
*, | ||
name: str, | ||
connection_qualified_name: Optional[str] = None, | ||
database_name: Optional[str] = None, | ||
database_qualified_name: Optional[str] = None, | ||
schema_name: Optional[str] = None, | ||
schema_qualified_name: Optional[str] = None, | ||
table_name: Optional[str] = None, | ||
table_qualified_name: str, | ||
) -> TablePartition: | ||
attributes = TablePartition.Attributes.creator( | ||
name=name, | ||
connection_qualified_name=connection_qualified_name, | ||
database_name=database_name, | ||
database_qualified_name=database_qualified_name, | ||
schema_name=schema_name, | ||
schema_qualified_name=schema_qualified_name, | ||
table_name=table_name, | ||
table_qualified_name=table_qualified_name, | ||
) | ||
return cls(attributes=attributes) | ||
|
||
@classmethod | ||
@init_guid | ||
def updater(cls, *, name: str, qualified_name: str) -> TablePartition: | ||
validate_required_fields( | ||
["name", "qualified_name"], | ||
[name, qualified_name], | ||
) | ||
table_partition = TablePartition( | ||
attributes=TablePartition.Attributes( | ||
qualified_name=qualified_name, name=name | ||
) | ||
) | ||
return table_partition | ||
|
||
def trim_to_required(self: TablePartition) -> TablePartition: | ||
return self.updater( | ||
qualified_name=self.qualified_name or "", name=self.name or "" | ||
) |
59 changes: 59 additions & 0 deletions
59
pyatlan/generator/templates/methods/attribute/table_partition.jinja2
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,59 @@ | ||
|
||
@classmethod | ||
@init_guid | ||
def creator( | ||
cls, | ||
*, | ||
name: str, | ||
connection_qualified_name: Optional[str] = None, | ||
database_name: Optional[str] = None, | ||
database_qualified_name: Optional[str] = None, | ||
schema_name: Optional[str] = None, | ||
schema_qualified_name: Optional[str] = None, | ||
table_name: Optional[str] = None, | ||
table_qualified_name: str, | ||
) -> TablePartition.Attributes: | ||
validate_required_fields( | ||
["name", "table_qualified_name"], | ||
[name, table_qualified_name], | ||
) | ||
assert table_qualified_name # noqa: S101 | ||
table_qualified_name | ||
if connection_qualified_name: | ||
connector_name = AtlanConnectorType.get_connector_name( | ||
connection_qualified_name | ||
) | ||
else: | ||
connection_qn, connector_name = AtlanConnectorType.get_connector_name( | ||
table_qualified_name, "table_qualified_name", 6 | ||
) | ||
|
||
fields = table_qualified_name.split("/") | ||
|
||
connection_qualified_name = connection_qualified_name or connection_qn | ||
database_name = database_name or fields[3] | ||
schema_name = schema_name or fields[4] | ||
table_name = table_name or fields[5] | ||
database_qualified_name = ( | ||
database_qualified_name | ||
or f"{connection_qualified_name}/{database_name}" | ||
) | ||
schema_qualified_name = ( | ||
schema_qualified_name | ||
or f"{connection_qualified_name}/{database_name}" | ||
) | ||
|
||
qualified_name = f"{schema_qualified_name}/{name}" | ||
|
||
return TablePartition.Attributes( | ||
name=name, | ||
qualified_name=qualified_name, | ||
database_name=database_name, | ||
database_qualified_name=database_qualified_name, | ||
schema_name=schema_name, | ||
schema_qualified_name=schema_qualified_name, | ||
connector_name=connector_name, | ||
connection_qualified_name=connection_qualified_name, | ||
table_name=table_name, | ||
table_qualified_name=table_qualified_name, | ||
) |
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