MCPcopy Create free account
hub / github.com/google-research/language / process_columns

Function process_columns

language/xsp/data_preprocessing/schema_utils.py:139–161  ·  view source on GitHub ↗

Processes a column in a table to a TableColumn object.

(columns, tokenizer, table_name, aligned_schema_entities)

Source from the content-addressed store, hash-verified

137
138
139def process_columns(columns, tokenizer, table_name, aligned_schema_entities):
140 """Processes a column in a table to a TableColumn object."""
141 column_obj_list = list()
142 for column in columns:
143 column_obj = TableColumn()
144 column_obj.original_column_name = column['field name']
145 column_obj.column_name_wordpieces.extend(
146 get_wordpieces(
147 column_obj.original_column_name.replace('_', ' '), tokenizer)[0])
148 col_type = column['type'].lower()
149 if 'int' in col_type or 'float' in col_type or 'double' in col_type or 'decimal' in col_type:
150 col_type = 'number'
151 if 'varchar' in col_type or 'longtext' in col_type:
152 col_type = 'text'
153 column_obj.column_type = col_type
154 column_obj.table_name = table_name
155
156 column_obj.matches_to_utterance = column_obj.original_column_name.lower(
157 ).replace('_', ' ') in aligned_schema_entities
158
159 column_obj.is_foreign_key = column_is_foreign_key(column)
160 column_obj_list.append(column_obj)
161 return column_obj_list
162
163
164def process_table(table_name, columns, tokenizer, aligned_schema_entities):

Callers 1

process_tableFunction · 0.85

Calls 4

get_wordpiecesFunction · 0.90
TableColumnClass · 0.85
column_is_foreign_keyFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…