File tree Expand file tree Collapse file tree
libs/foundry-dev-tools/src/foundry_dev_tools/clients Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99if TYPE_CHECKING :
1010 import requests
1111
12- from foundry_dev_tools .utils .api_types import FolderRid , SourceRid
12+ from foundry_dev_tools .utils .api_types import Branch , FolderRid , SourceRid , TableRid
1313
1414
1515class TablesClient (APIClient ):
@@ -143,3 +143,44 @@ def list_tables(self, connection_rid: SourceRid) -> list[dict]:
143143 response_json = self .api_list_tables (connection_rid = connection_rid , page_token = next_page_token ).json ()
144144 tables .extend (response_json ["tables" ])
145145 return tables
146+
147+ def api_get_table_schema (self , table_rid : TableRid , branches : list [Branch ], ** kwargs ) -> requests .Response :
148+ """Retrieves schema for a Foundry table object per given list of branches.
149+
150+ Args:
151+ table_rid: The RID of the table to get schema for.
152+ branches: List of branch names to get schema for.
153+ **kwargs: gets passed to :py:meth:`APIClient.api_request`
154+
155+ Returns:
156+ requests.Response: The API response containing the table schema.
157+
158+ Example::
159+ >>> response = tables_client.api_get_table_schema("ri.foundry.main.dataset.abc123", ["master"])
160+ >>> schema = response.json()
161+ >>> schema
162+ {
163+ "fieldSchemaList": [
164+ {
165+ "type": "DECIMAL",
166+ "name": "column_A",
167+ "nullable": false,
168+ "precision": 38,
169+ "scale": 0
170+ },
171+ {
172+ "type": "STRING",
173+ "name": "column_B",
174+ "nullable": false
175+ }
176+ ],
177+ "primaryKey": null,
178+ "customMetadata": {"format": "snowflake"}
179+ }
180+ """
181+ return self .api_request (
182+ "POST" ,
183+ api_path = f"tables/{ table_rid } /schema" ,
184+ json = {"branches" : branches },
185+ ** kwargs ,
186+ )
You can’t perform that action at this time.
0 commit comments