(self, row, col_rows=None, trigger_rows=None)
| 2146 | aggregate_row.get('deterministic', False)) |
| 2147 | |
| 2148 | def _build_table_metadata(self, row, col_rows=None, trigger_rows=None): |
| 2149 | keyspace_name = row["keyspace_name"] |
| 2150 | cfname = row[self._table_name_col] |
| 2151 | |
| 2152 | col_rows = col_rows or self.keyspace_table_col_rows[keyspace_name][cfname] |
| 2153 | trigger_rows = trigger_rows or self.keyspace_table_trigger_rows[keyspace_name][cfname] |
| 2154 | |
| 2155 | if not col_rows: # CASSANDRA-8487 |
| 2156 | log.warning("Building table metadata with no column meta for %s.%s", |
| 2157 | keyspace_name, cfname) |
| 2158 | |
| 2159 | table_meta = TableMetadata(keyspace_name, cfname) |
| 2160 | |
| 2161 | try: |
| 2162 | comparator = types.lookup_casstype(row["comparator"]) |
| 2163 | table_meta.comparator = comparator |
| 2164 | |
| 2165 | is_dct_comparator = issubclass(comparator, types.DynamicCompositeType) |
| 2166 | is_composite_comparator = issubclass(comparator, types.CompositeType) |
| 2167 | column_name_types = comparator.subtypes if is_composite_comparator else (comparator,) |
| 2168 | |
| 2169 | num_column_name_components = len(column_name_types) |
| 2170 | last_col = column_name_types[-1] |
| 2171 | |
| 2172 | column_aliases = row.get("column_aliases", None) |
| 2173 | |
| 2174 | clustering_rows = [r for r in col_rows |
| 2175 | if r.get('type', None) == "clustering_key"] |
| 2176 | if len(clustering_rows) > 1: |
| 2177 | clustering_rows = sorted(clustering_rows, key=lambda row: row.get('component_index')) |
| 2178 | |
| 2179 | if column_aliases is not None: |
| 2180 | column_aliases = json.loads(column_aliases) |
| 2181 | |
| 2182 | if not column_aliases: # json load failed or column_aliases empty PYTHON-562 |
| 2183 | column_aliases = [r.get('column_name') for r in clustering_rows] |
| 2184 | |
| 2185 | if is_composite_comparator: |
| 2186 | if issubclass(last_col, types.ColumnToCollectionType): |
| 2187 | # collections |
| 2188 | is_compact = False |
| 2189 | has_value = False |
| 2190 | clustering_size = num_column_name_components - 2 |
| 2191 | elif (len(column_aliases) == num_column_name_components - 1 and |
| 2192 | issubclass(last_col, types.UTF8Type)): |
| 2193 | # aliases? |
| 2194 | is_compact = False |
| 2195 | has_value = False |
| 2196 | clustering_size = num_column_name_components - 1 |
| 2197 | else: |
| 2198 | # compact table |
| 2199 | is_compact = True |
| 2200 | has_value = column_aliases or not col_rows |
| 2201 | clustering_size = num_column_name_components |
| 2202 | |
| 2203 | # Some thrift tables define names in composite types (see PYTHON-192) |
| 2204 | if not column_aliases and hasattr(comparator, 'fieldnames'): |
| 2205 | column_aliases = filter(None, comparator.fieldnames) |
no test coverage detected