|
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 |
@@ -279,26 +281,25 @@ def query_view_names_and_types( |
279 | 281 |
|
280 | 282 | return tables |
281 | 283 |
|
282 | | - @staticmethod |
283 | 284 | def get_table_description( |
284 | | - schema_name: str, table_name: str, inspector: Inspector |
| 285 | + self, schema_name: str, table_name: str, inspector: Inspector |
285 | 286 | ) -> Optional[str]: |
286 | 287 | description = None |
287 | 288 | try: |
288 | | - table_info: dict = inspector.get_table_comment(table_name, schema_name) |
| 289 | + with self.engine.connect() as conn: |
| 290 | + rows = conn.execute( |
| 291 | + sql.text(STARROCKS_TABLE_COMMENTS), |
| 292 | + {"table_name": table_name, "schema": schema_name}, |
| 293 | + ) |
| 294 | + for row in rows: |
| 295 | + description = row[0] |
| 296 | + break |
289 | 297 | except Exception as exc: # pylint: disable=broad-except |
290 | 298 | logger.debug(traceback.format_exc()) |
291 | 299 | logger.warning( |
292 | 300 | f"Table description error for table [{schema_name}.{table_name}]: {exc}" |
293 | 301 | ) |
294 | | - else: |
295 | | - description = table_info.get("text") |
296 | | - |
297 | | - if description is None: |
298 | | - return None |
299 | | - if isinstance(description, (list, tuple)) and len(description) > 0: |
300 | | - return description[0] |
301 | | - return description |
| 302 | + return description or None |
302 | 303 |
|
303 | 304 | def _get_columns(self, table_name, schema=None): |
304 | 305 | """Get column information and primary key columns of the specified table""" |
@@ -536,4 +537,3 @@ def close(self): |
536 | 537 | self.engine.dispose() |
537 | 538 | logger.debug("StarRocks SQLAlchemy engine closed successfully") |
538 | 539 | super().close() |
539 | | - |
0 commit comments