@@ -93,30 +93,29 @@ def _get_table_info(max_workers: int = 8) -> Dict[str, str]:
93
93
return table_info
94
94
95
95
96
- def _get_column_info (table_name : str , max_workers : int = 8 ) -> List [Dict [str , str ]]:
96
+ def _get_column_info (
97
+ table_name : str , urn_table_mapping : Dict [str , str ], max_workers : int = 8
98
+ ) -> List [Dict [str , str ]]:
97
99
"""table_name에 해당하는 컬럼 이름과 설명을 가져오는 함수
98
100
99
101
Args:
100
102
table_name (str): 테이블 이름
103
+ urn_table_mapping (Dict[str, str]): URN-테이블명 매핑 딕셔너리
101
104
max_workers (int, optional): 병렬 처리에 사용할 최대 쓰레드 수. Defaults to 8.
102
105
103
106
Returns:
104
107
List[Dict[str, str]]: 컬럼 정보 리스트
105
108
"""
106
- fetcher = _get_fetcher ()
107
- urns = fetcher .get_urns ()
109
+ # 해당 테이블의 URN 직접 찾기
110
+ target_urn = urn_table_mapping .get (table_name )
111
+ if not target_urn :
112
+ return []
108
113
109
- results = parallel_process (
110
- urns ,
111
- lambda urn : _process_column_info (urn , table_name , fetcher ),
112
- max_workers = max_workers ,
113
- show_progress = False ,
114
- )
114
+ # Fetcher 생성 및 컬럼 정보 가져오기
115
+ fetcher = _get_fetcher ()
116
+ column_info = fetcher .get_column_names_and_descriptions (target_urn )
115
117
116
- for result in results :
117
- if result :
118
- return result
119
- return []
118
+ return column_info
120
119
121
120
122
121
def get_info_from_db (max_workers : int = 8 ) -> List [Document ]:
@@ -130,9 +129,20 @@ def get_info_from_db(max_workers: int = 8) -> List[Document]:
130
129
"""
131
130
table_info = _get_table_info (max_workers = max_workers )
132
131
132
+ # URN-테이블명 매핑을 한 번만 생성
133
+ fetcher = _get_fetcher ()
134
+ urns = list (fetcher .get_urns ())
135
+ urn_table_mapping = {}
136
+ for urn in urns :
137
+ table_name = fetcher .get_table_name (urn )
138
+ if table_name :
139
+ urn_table_mapping [table_name ] = urn
140
+
133
141
def process_table_info (item : tuple [str , str ]) -> str :
134
142
table_name , table_description = item
135
- column_info = _get_column_info (table_name , max_workers = max_workers )
143
+ column_info = _get_column_info (
144
+ table_name , urn_table_mapping , max_workers = max_workers
145
+ )
136
146
column_info_str = "\n " .join (
137
147
[
138
148
f"{ col ['column_name' ]} : { col ['column_description' ]} "
0 commit comments