Processes a column in a table to a TableColumn object.
(columns, tokenizer, table_name, aligned_schema_entities)
| 137 | |
| 138 | |
| 139 | def 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 | |
| 164 | def process_table(table_name, columns, tokenizer, aligned_schema_entities): |
no test coverage detected
searching dependent graphs…