(self, meta, col_rows, compact_static=False, is_dense=False, virtual=False)
| 2616 | return dict((o, row.get(o)) for o in self.recognized_table_options if o in row) |
| 2617 | |
| 2618 | def _build_table_columns(self, meta, col_rows, compact_static=False, is_dense=False, virtual=False): |
| 2619 | # partition key |
| 2620 | partition_rows = [r for r in col_rows |
| 2621 | if r.get('kind', None) == "partition_key"] |
| 2622 | if len(partition_rows) > 1: |
| 2623 | partition_rows = sorted(partition_rows, key=lambda row: row.get('position')) |
| 2624 | for r in partition_rows: |
| 2625 | # we have to add meta here (and not in the later loop) because TableMetadata.columns is an |
| 2626 | # OrderedDict, and it assumes keys are inserted first, in order, when exporting CQL |
| 2627 | column_meta = self._build_column_metadata(meta, r) |
| 2628 | meta.columns[column_meta.name] = column_meta |
| 2629 | meta.partition_key.append(meta.columns[r.get('column_name')]) |
| 2630 | |
| 2631 | # clustering key |
| 2632 | if not compact_static: |
| 2633 | clustering_rows = [r for r in col_rows |
| 2634 | if r.get('kind', None) == "clustering"] |
| 2635 | if len(clustering_rows) > 1: |
| 2636 | clustering_rows = sorted(clustering_rows, key=lambda row: row.get('position')) |
| 2637 | for r in clustering_rows: |
| 2638 | column_meta = self._build_column_metadata(meta, r) |
| 2639 | meta.columns[column_meta.name] = column_meta |
| 2640 | meta.clustering_key.append(meta.columns[r.get('column_name')]) |
| 2641 | |
| 2642 | for col_row in (r for r in col_rows |
| 2643 | if r.get('kind', None) not in ('partition_key', 'clustering_key')): |
| 2644 | column_meta = self._build_column_metadata(meta, col_row) |
| 2645 | if is_dense and column_meta.cql_type == types.cql_empty_type: |
| 2646 | continue |
| 2647 | if compact_static and not column_meta.is_static: |
| 2648 | # for compact static tables, we omit the clustering key and value, and only add the logical columns. |
| 2649 | # They are marked not static so that it generates appropriate CQL |
| 2650 | continue |
| 2651 | if compact_static: |
| 2652 | column_meta.is_static = False |
| 2653 | meta.columns[column_meta.name] = column_meta |
| 2654 | |
| 2655 | def _build_view_metadata(self, row, col_rows=None): |
| 2656 | keyspace_name = row["keyspace_name"] |
no test coverage detected