|
9 | 9 | # See the License for the specific language governing permissions and |
10 | 10 | # limitations under the License. |
11 | 11 | """StarRocks source module""" |
| 12 | + |
12 | 13 | import re |
13 | 14 | import traceback |
14 | 15 | from typing import Dict, Iterable, List, Optional, Tuple, cast |
|
41 | 42 | STARROCKS_GET_TABLE_NAMES, |
42 | 43 | STARROCKS_PARTITION_DETAILS, |
43 | 44 | STARROCKS_SHOW_FULL_COLUMNS, |
| 45 | + STARROCKS_TABLE_COMMENTS, |
44 | 46 | ) |
45 | 47 | from metadata.utils.logger import ingestion_logger |
46 | 48 | from metadata.utils.ssl_manager import SSLManager, check_ssl_and_init |
@@ -269,26 +271,25 @@ def query_view_names_and_types( |
269 | 271 |
|
270 | 272 | return tables |
271 | 273 |
|
272 | | - @staticmethod |
273 | 274 | def get_table_description( |
274 | | - schema_name: str, table_name: str, inspector: Inspector |
| 275 | + self, schema_name: str, table_name: str, inspector: Inspector |
275 | 276 | ) -> Optional[str]: |
276 | 277 | description = None |
277 | 278 | try: |
278 | | - table_info: dict = inspector.get_table_comment(table_name, schema_name) |
| 279 | + with self.engine.connect() as conn: |
| 280 | + rows = conn.execute( |
| 281 | + sql.text(STARROCKS_TABLE_COMMENTS), |
| 282 | + {"table_name": table_name, "schema": schema_name}, |
| 283 | + ) |
| 284 | + for row in rows: |
| 285 | + description = row[0] |
| 286 | + break |
279 | 287 | except Exception as exc: # pylint: disable=broad-except |
280 | 288 | logger.debug(traceback.format_exc()) |
281 | 289 | logger.warning( |
282 | 290 | f"Table description error for table [{schema_name}.{table_name}]: {exc}" |
283 | 291 | ) |
284 | | - else: |
285 | | - description = table_info.get("text") |
286 | | - |
287 | | - if description is None: |
288 | | - return None |
289 | | - if isinstance(description, (list, tuple)) and len(description) > 0: |
290 | | - return description[0] |
291 | | - return description |
| 292 | + return description or None |
292 | 293 |
|
293 | 294 | def _get_columns(self, table_name, schema=None): |
294 | 295 | """Get column information and primary key columns of the specified table""" |
@@ -526,4 +527,3 @@ def close(self): |
526 | 527 | self.engine.dispose() |
527 | 528 | logger.debug("StarRocks SQLAlchemy engine closed successfully") |
528 | 529 | super().close() |
529 | | - |
0 commit comments