Skip to content

Commit b6ab03d

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

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
@@ -269,26 +271,25 @@ def query_view_names_and_types(
269271

270272
return tables
271273

272-
@staticmethod
273274
def get_table_description(
274-
schema_name: str, table_name: str, inspector: Inspector
275+
self, schema_name: str, table_name: str, inspector: Inspector
275276
) -> Optional[str]:
276277
description = None
277278
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
279287
except Exception as exc: # pylint: disable=broad-except
280288
logger.debug(traceback.format_exc())
281289
logger.warning(
282290
f"Table description error for table [{schema_name}.{table_name}]: {exc}"
283291
)
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
292293

293294
def _get_columns(self, table_name, schema=None):
294295
"""Get column information and primary key columns of the specified table"""
@@ -526,4 +527,3 @@ def close(self):
526527
self.engine.dispose()
527528
logger.debug("StarRocks SQLAlchemy engine closed successfully")
528529
super().close()
529-

0 commit comments

Comments
 (0)