Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Metadata: 接入计算平台时,table_id生成规避尾部下划线情况 --story=121740589 #4880

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bkmonitor/metadata/models/data_link/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def clean_redundant_underscores(table_id: str) -> str:
"""
while '__' in table_id:
table_id = table_id.replace('__', '_')
table_id = table_id.rstrip('_')
return table_id


Expand Down Expand Up @@ -84,9 +85,6 @@ def compose_bkdata_table_id(table_id: str, strategy: str = None) -> str:
else:
table_id = f'bkm_{table_id}'

# 确保不会出现连续的下划线
table_id = clean_redundant_underscores(table_id)

# 计算哈希值, 采用 hash 方式确保 table_id 唯一
hash_suffix = hashlib.md5(table_id.encode()).hexdigest()[:5]

Expand All @@ -100,6 +98,8 @@ def compose_bkdata_table_id(table_id: str, strategy: str = None) -> str:
else:
table_id = f"{table_id}{suffix}"

table_id = clean_redundant_underscores(table_id)

return table_id


Expand Down