Skip to content

Commit c827b6a

Browse files
fix(starrocks): use direct query for table comment instead of MySQL dialect (#26692)
1 parent eedc923 commit c827b6a

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • ingestion/src/metadata/ingestion/source/database/starrocks

ingestion/src/metadata/ingestion/source/database/starrocks/metadata.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# See the License for the specific language governing permissions and
1010
# limitations under the License.
1111
"""StarRocks source module"""
12+
1213
import re
1314
import traceback
1415
from typing import Dict, Iterable, List, Optional, Tuple, cast
@@ -41,6 +42,7 @@
4142
STARROCKS_GET_TABLE_NAMES,
4243
STARROCKS_PARTITION_DETAILS,
4344
STARROCKS_SHOW_FULL_COLUMNS,
45+
STARROCKS_TABLE_COMMENTS,
4446
)
4547
from metadata.utils.logger import ingestion_logger
4648
from metadata.utils.ssl_manager import SSLManager, check_ssl_and_init
@@ -279,26 +281,25 @@ def query_view_names_and_types(
279281

280282
return tables
281283

282-
@staticmethod
283284
def get_table_description(
284-
schema_name: str, table_name: str, inspector: Inspector
285+
self, schema_name: str, table_name: str, inspector: Inspector
285286
) -> Optional[str]:
286287
description = None
287288
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
289297
except Exception as exc: # pylint: disable=broad-except
290298
logger.debug(traceback.format_exc())
291299
logger.warning(
292300
f"Table description error for table [{schema_name}.{table_name}]: {exc}"
293301
)
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
302303

303304
def _get_columns(self, table_name, schema=None):
304305
"""Get column information and primary key columns of the specified table"""
@@ -536,4 +537,3 @@ def close(self):
536537
self.engine.dispose()
537538
logger.debug("StarRocks SQLAlchemy engine closed successfully")
538539
super().close()
539-

0 commit comments

Comments
 (0)