-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #473 from atlanhq/FT-896
FT-896: Implemented `creators()` and `updaters()` for `TablePartition`
- Loading branch information
Showing
9 changed files
with
649 additions
and
10 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
83 changes: 83 additions & 0 deletions
83
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,83 @@ | ||
|
||
@overload | ||
@classmethod | ||
def creator( | ||
cls, | ||
*, | ||
name: str, | ||
table_qualified_name: str, | ||
) -> TablePartition: | ||
""" | ||
Builds the minimal object necessary to create a table partition. | ||
|
||
:param name: name of the table partition | ||
:param table_qualified_name: unique name of the table in which this table partition exists | ||
:returns: the minimal request necessary to create the table partition | ||
""" | ||
|
||
@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: | ||
""" | ||
Builds the minimal object necessary to create a table partition. | ||
|
||
:param name: name of the TablePartition | ||
:param connection_qualified_name: unique name of the connection in which to create the TablePartition | ||
:param database_name: simple name of the Database in which to create the TablePartition | ||
:param database_qualified_name: unique name of the Database in which to create the TablePartition | ||
:param schema_name: simple name of the Schema in which to create the TablePartition | ||
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition | ||
:param table_name: simple name of the Table in which to create the TablePartition | ||
:param table_qualified_name: unique name of the table in which this table partition exists | ||
:returns: the minimal request necessary to create the table partition | ||
""" | ||
|
||
@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: | ||
""" | ||
Builds the minimal object necessary to create a table partition. | ||
|
||
:param name: name of the TablePartition | ||
:param connection_qualified_name: unique name of the connection in which to create the TablePartition | ||
:param database_name: simple name of the Database in which to create the TablePartition | ||
:param database_qualified_name: unique name of the Database in which to create the TablePartition | ||
:param schema_name: simple name of the Schema in which to create the TablePartition | ||
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition | ||
:param table_name: simple name of the Table in which to create the TablePartition | ||
:param table_qualified_name: unique name of the table in which this table partition exists | ||
:returns: the minimal request necessary to create the table partition | ||
""" | ||
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) |
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
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
|
||
@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: | ||
""" | ||
Builds the minimal object necessary to create a table partition. | ||
|
||
:param name: name of the TablePartition | ||
:param connection_qualified_name: unique name of the connection in which to create the TablePartition | ||
:param database_name: simple name of the Database in which to create the TablePartition | ||
:param database_qualified_name: unique name of the Database in which to create the TablePartition | ||
:param schema_name: simple name of the Schema in which to create the TablePartition | ||
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition | ||
:param table_name: simple name of the Table in which to create the TablePartition | ||
:param table_qualified_name: unique name of the table in which this table partition exists | ||
:returns: the minimal request necessary to create the table partition | ||
""" | ||
validate_required_fields( | ||
["name", "table_qualified_name"], | ||
[name, table_qualified_name], | ||
) | ||
assert table_qualified_name # noqa: S101 | ||
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"{database_qualified_name}/{schema_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, | ||
) |
Oops, something went wrong.