diff --git a/sql/engines/goinception.py b/sql/engines/goinception.py index 710c81120d..526c73902f 100644 --- a/sql/engines/goinception.py +++ b/sql/engines/goinception.py @@ -318,7 +318,9 @@ def get_table_ref(query_tree, db_name=None): # 首先识别所有的临时表名 if "With" in query_tree: logger.warning(query_tree["With"]) - with_definitions = query_tree["With"].get("CTEs", []) # 假设临时表定义在CTEs键下 + with_definitions = query_tree["With"].get( + "CTEs", [] + ) # 假设临时表定义在CTEs键下 for definition in with_definitions: temporary_tables.add(definition["Name"]["O"]) # 获取临时表的名称 @@ -335,11 +337,15 @@ def get_table_ref(query_tree, db_name=None): snodes = tree.find_max_tree("Source") if snodes: for snode in snodes: - schema_name = snode["Source"].get("Schema", {}).get("O") or db_name + schema_name = ( + snode["Source"].get("Schema", {}).get("O") or db_name + ) table_name = snode["Source"].get("Name", {}).get("O", "") # 检查表名是否为临时表,如果不是则添加到结果中 if table_name not in temporary_tables: - table_ref.append({"schema": schema_name, "name": table_name}) + table_ref.append( + {"schema": schema_name, "name": table_name} + ) # assert: source node must exists if table_refs node exists. # else: # raise Exception("GoInception Error: not found source node") @@ -385,12 +391,13 @@ def get_session_variables(instance): set_session_sql += f"inception set session {k} = '{v}';\n" return variables, set_session_sql + def remove_duplicates(table_list): unique_tables = [] seen = set() for table in table_list: - identifier = (table['schema'], table['name']) + identifier = (table["schema"], table["name"]) if identifier not in seen: seen.add(identifier) unique_tables.append(table) - return unique_tables \ No newline at end of file + return unique_tables