Get schema and metadata information about a Spanner table. Args: project_id (str): The Google Cloud project id. instance_id (str): The Spanner instance id. database_id (str): The Spanner database id. table_id (str): The Spanner table id. credentials (Credentials): Th
(
project_id: str,
instance_id: str,
database_id: str,
table_name: str,
credentials: Credentials,
named_schema: str = "",
)
| 74 | |
| 75 | |
| 76 | def get_table_schema( |
| 77 | project_id: str, |
| 78 | instance_id: str, |
| 79 | database_id: str, |
| 80 | table_name: str, |
| 81 | credentials: Credentials, |
| 82 | named_schema: str = "", |
| 83 | ) -> dict: |
| 84 | """Get schema and metadata information about a Spanner table. |
| 85 | |
| 86 | Args: |
| 87 | project_id (str): The Google Cloud project id. |
| 88 | instance_id (str): The Spanner instance id. |
| 89 | database_id (str): The Spanner database id. |
| 90 | table_id (str): The Spanner table id. |
| 91 | credentials (Credentials): The credentials to use for the request. |
| 92 | named_schema (str): The named schema to list tables in. Default is empty |
| 93 | string "" to search for tables in the default schema of the database. |
| 94 | |
| 95 | Returns: |
| 96 | dict: Dictionary with the Spanner table schema information. |
| 97 | |
| 98 | Examples: |
| 99 | >>> get_table_schema("my_project", "my_instance", "my_database", |
| 100 | ... "my_table") |
| 101 | { |
| 102 | "status": "SUCCESS", |
| 103 | "results": |
| 104 | { |
| 105 | "schema": { |
| 106 | 'colA': { |
| 107 | 'SPANNER_TYPE': 'STRING(1024)', |
| 108 | 'TABLE_SCHEMA': '', |
| 109 | 'ORDINAL_POSITION': 1, |
| 110 | 'COLUMN_DEFAULT': None, |
| 111 | 'IS_NULLABLE': 'NO', |
| 112 | 'IS_GENERATED': 'NEVER', |
| 113 | 'GENERATION_EXPRESSION': None, |
| 114 | 'IS_STORED': None, |
| 115 | 'KEY_COLUMN_USAGE': [ |
| 116 | # This part is added if it's a key column |
| 117 | { |
| 118 | 'CONSTRAINT_NAME': 'PK_Table1', |
| 119 | 'ORDINAL_POSITION': 1, |
| 120 | 'POSITION_IN_UNIQUE_CONSTRAINT': None |
| 121 | } |
| 122 | ] |
| 123 | }, |
| 124 | 'colB': { ... }, |
| 125 | ... |
| 126 | }, |
| 127 | "metadata": [ |
| 128 | { |
| 129 | 'TABLE_SCHEMA': '', |
| 130 | 'TABLE_NAME': 'MyTable', |
| 131 | 'TABLE_TYPE': 'BASE TABLE', |
| 132 | 'PARENT_TABLE_NAME': NULL, |
| 133 | 'ON_DELETE_ACTION': NULL, |
nothing calls this directly
no test coverage detected