@@ -93,30 +93,29 @@ def _get_table_info(max_workers: int = 8) -> Dict[str, str]:
9393 return table_info
9494
9595
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 ]]:
9799 """table_name에 해당하는 컬럼 이름과 설명을 가져오는 함수
98100
99101 Args:
100102 table_name (str): 테이블 이름
103+ urn_table_mapping (Dict[str, str]): URN-테이블명 매핑 딕셔너리
101104 max_workers (int, optional): 병렬 처리에 사용할 최대 쓰레드 수. Defaults to 8.
102105
103106 Returns:
104107 List[Dict[str, str]]: 컬럼 정보 리스트
105108 """
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 []
108113
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 )
115117
116- for result in results :
117- if result :
118- return result
119- return []
118+ return column_info
120119
121120
122121def 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]:
130129 """
131130 table_info = _get_table_info (max_workers = max_workers )
132131
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+
133141 def process_table_info (item : tuple [str , str ]) -> str :
134142 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+ )
136146 column_info_str = "\n " .join (
137147 [
138148 f"{ col ['column_name' ]} : { col ['column_description' ]} "
0 commit comments