Skip to content

Commit 87acafb

Browse files
authored
Merge branch 'master' into joshua/drop-views-on-disconnect
2 parents 2d2c26d + 3863f20 commit 87acafb

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

crates/schema/src/schema.rs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,19 @@ impl TableSchema {
603603
/// fn my_anonymous_view(ctx: &AnonymousViewContext, x: u32, y: u32) -> Vec<MyTable> { ... }
604604
/// ```
605605
///
606-
/// The above views are materialized with the following schemas:
606+
/// The above views are materialized with the following schema:
607607
///
608608
/// my_view:
609609
///
610-
/// | sender | arg_id | a | b |
611-
/// |----------|--------|-----|-----|
612-
/// | Identity | 1 | u32 | u32 |
610+
/// | sender | arg_id | a | b |
611+
/// |----------------|--------|-----|-----|
612+
/// | (some = 0x...) | u64 | u32 | u32 |
613613
///
614614
/// my_anonymous_view:
615615
///
616-
/// | arg_id | a | b |
617-
/// |--------|-----|-----|
618-
/// | 1 | u32 | u32 |
616+
/// | sender | arg_id | a | b |
617+
/// |-------------|--------|-----|-----|
618+
/// | (none = ()) | u64 | u32 | u32 |
619619
///
620620
/// Note, `arg_id` is a foreign key into `st_view_arg`.
621621
pub fn from_view_def(module_def: &ModuleDef, view_def: &ViewDef) -> Self {
@@ -631,17 +631,20 @@ impl TableSchema {
631631
let n = return_columns.len() + 2;
632632
let mut columns = Vec::with_capacity(n);
633633

634+
let sender_col_name = "sender";
635+
let arg_id_col_name = "arg_id";
636+
634637
columns.push(ColumnSchema {
635638
table_id: TableId::SENTINEL,
636639
col_pos: ColId(0),
637-
col_name: "sender".into(),
640+
col_name: sender_col_name.into(),
638641
col_type: AlgebraicType::option(AlgebraicType::identity()),
639642
});
640643

641644
columns.push(ColumnSchema {
642645
table_id: TableId::SENTINEL,
643646
col_pos: ColId(1),
644-
col_name: "arg_id".into(),
647+
col_name: arg_id_col_name.into(),
645648
col_type: AlgebraicType::U64,
646649
});
647650

@@ -654,6 +657,15 @@ impl TableSchema {
654657
.map(|(col_pos, schema)| ColumnSchema { col_pos, ..schema }),
655658
);
656659

660+
let index_name = format!("{}_{}_{}_idx_btree", name, sender_col_name, arg_id_col_name);
661+
662+
let indexes = vec![IndexSchema {
663+
index_id: IndexId::SENTINEL,
664+
table_id: TableId::SENTINEL,
665+
index_name: index_name.into_boxed_str(),
666+
index_algorithm: IndexAlgorithm::BTree(col_list![0, 1].into()),
667+
}];
668+
657669
let table_access = if *is_public {
658670
StAccess::Public
659671
} else {
@@ -664,7 +676,7 @@ impl TableSchema {
664676
TableId::SENTINEL,
665677
(*name).clone().into(),
666678
columns,
667-
vec![],
679+
indexes,
668680
vec![],
669681
vec![],
670682
StTableType::User,

0 commit comments

Comments
 (0)