Skip to content

Commit e772fa2

Browse files
authored
Merge pull request #473 from atlanhq/FT-896
FT-896: Implemented `creators()` and `updaters()` for `TablePartition`
2 parents 67bd4ee + 9c957aa commit e772fa2

File tree

9 files changed

+649
-10
lines changed

9 files changed

+649
-10
lines changed

Diff for: pyatlan/generator/templates/methods/asset/column.jinja2

+67-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,18 @@
88
parent_qualified_name: str,
99
parent_type: type,
1010
order: int,
11-
) -> Column: ...
11+
) -> Column:
12+
"""
13+
Builds the minimal object necessary to create a Column.
14+
15+
:param name: name of the Column
16+
:param parent_qualified_name: unique name of the table / view / materialized view
17+
/ table partition / snowflake dynamic table in which this Column exists
18+
:param parent_type: type of parent (table, view, materialized view,
19+
table partition, snowflake dynamic table), should be a TYPE_NAME static string
20+
:param order: the order the Column appears within its parent (the Column's position)
21+
:returns: the minimal request necessary to create the Column
22+
"""
1223

1324
@overload
1425
@classmethod
@@ -27,7 +38,27 @@
2738
table_name: str,
2839
table_qualified_name: str,
2940
connection_qualified_name: str,
30-
) -> Column: ...
41+
) -> Column:
42+
"""
43+
Builds the minimal object necessary to create a Column.
44+
45+
:param name: name of the Column
46+
:param parent_qualified_name: unique name of the table / view / materialized view
47+
/ table partition / snowflake dynamic table in which this Column exist
48+
:param parent_type: type of parent (table, view, materialized view,
49+
table partition, snowflake dynamic table), should be a TYPE_NAME static string
50+
:param order: the order the Column appears within its parent (the Column's position)
51+
:param parent_name: simple name of the table / view / materialized view / table partition
52+
/ snowflake dynamic table in which the Column should be created
53+
:param database_name: simple name of the database in which the Column should be created
54+
:param database_qualified_name: unique name of the database in which the Column should be created
55+
:param schema_name: simple name of the schema in which the Column should be created
56+
:param schema_qualified_name: unique name of the schema in which the Column should be created
57+
:param table_name: (deprecated - unused)
58+
:param table_qualified_name: (deprecated - unused)
59+
:param connection_qualified_name: unique name of the connection in which the Column should be created
60+
:returns: the minimal request necessary to create the Column
61+
"""
3162

3263
@classmethod
3364
@init_guid
@@ -47,6 +78,40 @@
4778
table_qualified_name: Optional[str] = None,
4879
connection_qualified_name: Optional[str] = None,
4980
) -> Column:
81+
"""
82+
Builds the minimal object necessary to create a Column.
83+
84+
:param name: name of the Column
85+
:param parent_qualified_name: unique name of the table / view / materialized view
86+
/ table partition / snowflake dynamic table in which this Column exists
87+
:param parent_type: type of parent (table, view, materialized view,
88+
table partition, snowflake dynamic table), should be a TYPE_NAME static string
89+
:param order: the order the Column appears within its parent (the Column's position)
90+
:param parent_name: simple name of the table / view / materialized view / table partition
91+
/ snowflake dynamic table in which the Column should be created
92+
:param database_name: simple name of the database in which the Column should be created
93+
:param database_qualified_name: unique name of the database in which the Column should be created
94+
:param schema_name: simple name of the schema in which the Column should be created
95+
:param schema_qualified_name: unique name of the schema in which the Column should be created
96+
:param table_name: (deprecated - unused)
97+
:param table_qualified_name: (deprecated - unused)
98+
:param connection_qualified_name: unique name of the connection in which the Column should be created
99+
:returns: the minimal request necessary to create the Column
100+
"""
101+
if table_name:
102+
warn(
103+
("`table_name` is deprecated, please use `parent_name` instead"),
104+
DeprecationWarning,
105+
stacklevel=2,
106+
)
107+
if table_qualified_name:
108+
warn(
109+
(
110+
"`table_qualified_name` is deprecated, please use `parent_qualified_name` instead"
111+
),
112+
DeprecationWarning,
113+
stacklevel=2,
114+
)
50115
return Column(
51116
attributes=Column.Attributes.create(
52117
name=name,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
2+
@overload
3+
@classmethod
4+
def creator(
5+
cls,
6+
*,
7+
name: str,
8+
table_qualified_name: str,
9+
) -> TablePartition:
10+
"""
11+
Builds the minimal object necessary to create a table partition.
12+
13+
:param name: name of the table partition
14+
:param table_qualified_name: unique name of the table in which this table partition exists
15+
:returns: the minimal request necessary to create the table partition
16+
"""
17+
18+
@overload
19+
@classmethod
20+
def creator(
21+
cls,
22+
*,
23+
name: str,
24+
connection_qualified_name: str,
25+
database_name: str,
26+
database_qualified_name: str,
27+
schema_name: str,
28+
schema_qualified_name: str,
29+
table_name: str,
30+
table_qualified_name: str,
31+
) -> TablePartition:
32+
"""
33+
Builds the minimal object necessary to create a table partition.
34+
35+
:param name: name of the TablePartition
36+
:param connection_qualified_name: unique name of the connection in which to create the TablePartition
37+
:param database_name: simple name of the Database in which to create the TablePartition
38+
:param database_qualified_name: unique name of the Database in which to create the TablePartition
39+
:param schema_name: simple name of the Schema in which to create the TablePartition
40+
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition
41+
:param table_name: simple name of the Table in which to create the TablePartition
42+
:param table_qualified_name: unique name of the table in which this table partition exists
43+
:returns: the minimal request necessary to create the table partition
44+
"""
45+
46+
@classmethod
47+
@init_guid
48+
def creator(
49+
cls,
50+
*,
51+
name: str,
52+
connection_qualified_name: Optional[str] = None,
53+
database_name: Optional[str] = None,
54+
database_qualified_name: Optional[str] = None,
55+
schema_name: Optional[str] = None,
56+
schema_qualified_name: Optional[str] = None,
57+
table_name: Optional[str] = None,
58+
table_qualified_name: str,
59+
) -> TablePartition:
60+
"""
61+
Builds the minimal object necessary to create a table partition.
62+
63+
:param name: name of the TablePartition
64+
:param connection_qualified_name: unique name of the connection in which to create the TablePartition
65+
:param database_name: simple name of the Database in which to create the TablePartition
66+
:param database_qualified_name: unique name of the Database in which to create the TablePartition
67+
:param schema_name: simple name of the Schema in which to create the TablePartition
68+
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition
69+
:param table_name: simple name of the Table in which to create the TablePartition
70+
:param table_qualified_name: unique name of the table in which this table partition exists
71+
:returns: the minimal request necessary to create the table partition
72+
"""
73+
attributes = TablePartition.Attributes.creator(
74+
name=name,
75+
connection_qualified_name=connection_qualified_name,
76+
database_name=database_name,
77+
database_qualified_name=database_qualified_name,
78+
schema_name=schema_name,
79+
schema_qualified_name=schema_qualified_name,
80+
table_name=table_name,
81+
table_qualified_name=table_qualified_name,
82+
)
83+
return cls(attributes=attributes)

Diff for: pyatlan/generator/templates/methods/attribute/column.jinja2

+22-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,26 @@
1717
table_qualified_name: Optional[str] = None,
1818
connection_qualified_name: Optional[str] = None,
1919
) -> Column.Attributes:
20+
"""
21+
Builds the minimal object necessary to create a Column.
22+
23+
:param name: name of the Column
24+
:param parent_qualified_name: unique name of the table / view / materialized view
25+
/ table partition / snowflake dynamic table in which this Column exist
26+
:param parent_type: type of parent (table, view, materialized view,
27+
table partition, snowflake dynamic table), should be a TYPE_NAME static string
28+
:param order: the order the Column appears within its parent (the Column's position)
29+
:param parent_name: simple name of the table / view / materialized view
30+
/ table partition / snowflake dynamic table in which the Column is created
31+
:param database_name: simple name of the database in which the Column should be created
32+
:param database_qualified_name: unique name of the database in which the Column should be created
33+
:param schema_name: simple name of the schema in which the Column should be created
34+
:param schema_qualified_name: unique name of the schema in which the Column should be created
35+
:param table_name: (deprecated - unused)
36+
:param table_qualified_name: (deprecated - unused)
37+
:param connection_qualified_name: unique name of the connection in which the Column should be created
38+
:returns: the minimal request necessary to create the Column
39+
"""
2040
validate_required_fields(
2141
["name", "parent_qualified_name", "parent_type", "order"],
2242
[name, parent_qualified_name, parent_type, order],
@@ -73,11 +93,11 @@
7393
)
7494
column.view_name = parent_name
7595
elif parent_type == TablePartition:
76-
column.table_qualified_name = table_qualified_name
96+
column.table_qualified_name = parent_qualified_name
7797
column.table_partition = TablePartition.ref_by_qualified_name(
7898
parent_qualified_name
7999
)
80-
column.table_name = table_name
100+
column.table_name = parent_name
81101
elif parent_type == SnowflakeDynamicTable:
82102
column.table_qualified_name = parent_qualified_name
83103
column.snowflake_dynamic_table = (
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
2+
@classmethod
3+
@init_guid
4+
def creator(
5+
cls,
6+
*,
7+
name: str,
8+
connection_qualified_name: Optional[str] = None,
9+
database_name: Optional[str] = None,
10+
database_qualified_name: Optional[str] = None,
11+
schema_name: Optional[str] = None,
12+
schema_qualified_name: Optional[str] = None,
13+
table_name: Optional[str] = None,
14+
table_qualified_name: str,
15+
) -> TablePartition.Attributes:
16+
"""
17+
Builds the minimal object necessary to create a table partition.
18+
19+
:param name: name of the TablePartition
20+
:param connection_qualified_name: unique name of the connection in which to create the TablePartition
21+
:param database_name: simple name of the Database in which to create the TablePartition
22+
:param database_qualified_name: unique name of the Database in which to create the TablePartition
23+
:param schema_name: simple name of the Schema in which to create the TablePartition
24+
:param schema_qualified_name: unique name of the Schema in which to create the TablePartition
25+
:param table_name: simple name of the Table in which to create the TablePartition
26+
:param table_qualified_name: unique name of the table in which this table partition exists
27+
:returns: the minimal request necessary to create the table partition
28+
"""
29+
validate_required_fields(
30+
["name", "table_qualified_name"],
31+
[name, table_qualified_name],
32+
)
33+
assert table_qualified_name # noqa: S101
34+
if connection_qualified_name:
35+
connector_name = AtlanConnectorType.get_connector_name(
36+
connection_qualified_name
37+
)
38+
else:
39+
connection_qn, connector_name = AtlanConnectorType.get_connector_name(
40+
table_qualified_name, "table_qualified_name", 6
41+
)
42+
43+
fields = table_qualified_name.split("/")
44+
45+
connection_qualified_name = connection_qualified_name or connection_qn
46+
database_name = database_name or fields[3]
47+
schema_name = schema_name or fields[4]
48+
table_name = table_name or fields[5]
49+
database_qualified_name = (
50+
database_qualified_name
51+
or f"{connection_qualified_name}/{database_name}"
52+
)
53+
schema_qualified_name = (
54+
schema_qualified_name or f"{database_qualified_name}/{schema_name}"
55+
)
56+
57+
qualified_name = f"{schema_qualified_name}/{name}"
58+
59+
return TablePartition.Attributes(
60+
name=name,
61+
qualified_name=qualified_name,
62+
database_name=database_name,
63+
database_qualified_name=database_qualified_name,
64+
schema_name=schema_name,
65+
schema_qualified_name=schema_qualified_name,
66+
connector_name=connector_name,
67+
connection_qualified_name=connection_qualified_name,
68+
table_name=table_name,
69+
table_qualified_name=table_qualified_name,
70+
)

0 commit comments

Comments
 (0)