Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added link to predicate_children entity and fixed code #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions optd-persistent/src/bin/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ async fn init_all_tables() -> Result<(), sea_orm::error::DbErr> {
latest_winner: Set(None),
in_progress: Set(true),
is_optimized: Set(false),
parent_id: Set(None),
};
cascades_group::Entity::insert(cascades_group)
.exec(&db)
Expand All @@ -288,7 +289,6 @@ async fn init_all_tables() -> Result<(), sea_orm::error::DbErr> {
group_id: Set(1),
fingerprint: Set(12345),
variant_tag: Set(0),
data: Set(json!(r#"{"expr": "index_scan"}"#)),
};
logical_expression::Entity::insert(logical_expression)
.exec(&db)
Expand All @@ -301,7 +301,6 @@ async fn init_all_tables() -> Result<(), sea_orm::error::DbErr> {
group_id: Set(1),
fingerprint: Set(12345),
variant_tag: Set(0),
data: Set(json!(r#"{"expr": "index_scan"}"#)),
};
physical_expression::Entity::insert(physical_expression)
.exec(&db)
Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
11 changes: 10 additions & 1 deletion optd-persistent/src/entities/cascades_group.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand All @@ -10,10 +10,19 @@ pub struct Model {
pub latest_winner: Option<i32>,
pub in_progress: bool,
pub is_optimized: bool,
pub parent_id: Option<i32>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(
belongs_to = "Entity",
from = "Column::ParentId",
to = "Column::Id",
on_update = "Cascade",
on_delete = "SetNull"
)]
SelfRef,
#[sea_orm(has_many = "super::group_winner::Entity")]
GroupWinner,
#[sea_orm(has_many = "super::logical_children::Entity")]
Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/constraint_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/database_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/event.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/group_winner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/index_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/logical_children.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
24 changes: 22 additions & 2 deletions optd-persistent/src/entities/logical_expression.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand All @@ -10,7 +10,6 @@ pub struct Model {
pub group_id: i32,
pub fingerprint: i64,
pub variant_tag: i16,
pub data: Json,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand All @@ -25,6 +24,8 @@ pub enum Relation {
CascadesGroup,
#[sea_orm(has_many = "super::logical_children::Entity")]
LogicalChildren,
#[sea_orm(has_many = "super::predicate_logical_expression_junction::Entity")]
PredicateLogicalExpressionJunction,
}

impl Related<super::logical_children::Entity> for Entity {
Expand All @@ -33,6 +34,12 @@ impl Related<super::logical_children::Entity> for Entity {
}
}

impl Related<super::predicate_logical_expression_junction::Entity> for Entity {
fn to() -> RelationDef {
Relation::PredicateLogicalExpressionJunction.def()
}
}

impl Related<super::cascades_group::Entity> for Entity {
fn to() -> RelationDef {
super::logical_children::Relation::CascadesGroup.def()
Expand All @@ -46,4 +53,17 @@ impl Related<super::cascades_group::Entity> for Entity {
}
}

impl Related<super::predicate::Entity> for Entity {
fn to() -> RelationDef {
super::predicate_logical_expression_junction::Relation::Predicate.def()
}
fn via() -> Option<RelationDef> {
Some(
super::predicate_logical_expression_junction::Relation::LogicalExpression
.def()
.rev(),
)
}
}

impl ActiveModelBehavior for ActiveModel {}
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/logical_property.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
6 changes: 5 additions & 1 deletion optd-persistent/src/entities/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

pub mod prelude;

Expand All @@ -20,6 +20,10 @@ pub mod physical_expression;
pub mod physical_expression_to_statistic_junction;
pub mod physical_property;
pub mod plan_cost;
pub mod predicate;
pub mod predicate_children;
pub mod predicate_logical_expression_junction;
pub mod predicate_physical_expression_junction;
pub mod statistic;
pub mod statistic_to_attribute_junction;
pub mod table_metadata;
Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/namespace_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/physical_children.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
24 changes: 22 additions & 2 deletions optd-persistent/src/entities/physical_expression.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand All @@ -10,7 +10,6 @@ pub struct Model {
pub group_id: i32,
pub fingerprint: i64,
pub variant_tag: i16,
pub data: Json,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
Expand All @@ -33,6 +32,8 @@ pub enum Relation {
PhysicalProperty,
#[sea_orm(has_many = "super::plan_cost::Entity")]
PlanCost,
#[sea_orm(has_many = "super::predicate_physical_expression_junction::Entity")]
PredicatePhysicalExpressionJunction,
}

impl Related<super::group_winner::Entity> for Entity {
Expand Down Expand Up @@ -65,6 +66,12 @@ impl Related<super::plan_cost::Entity> for Entity {
}
}

impl Related<super::predicate_physical_expression_junction::Entity> for Entity {
fn to() -> RelationDef {
Relation::PredicatePhysicalExpressionJunction.def()
}
}

impl Related<super::cascades_group::Entity> for Entity {
fn to() -> RelationDef {
super::physical_children::Relation::CascadesGroup.def()
Expand All @@ -78,6 +85,19 @@ impl Related<super::cascades_group::Entity> for Entity {
}
}

impl Related<super::predicate::Entity> for Entity {
fn to() -> RelationDef {
super::predicate_physical_expression_junction::Relation::Predicate.def()
}
fn via() -> Option<RelationDef> {
Some(
super::predicate_physical_expression_junction::Relation::PhysicalExpression
.def()
.rev(),
)
}
}

impl Related<super::statistic::Entity> for Entity {
fn to() -> RelationDef {
super::physical_expression_to_statistic_junction::Relation::Statistic.def()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/physical_property.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/plan_cost.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
15 changes: 15 additions & 0 deletions optd-persistent/src/entities/predicate_children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ pub enum Relation {
Predicate1,
}

pub struct PredicateChildrenLink;

impl Linked for PredicateChildrenLink {
type FromEntity = super::predicate::Entity;

type ToEntity = super::predicate::Entity;

fn link(&self) -> Vec<sea_orm::LinkDef> {
vec![
super::predicate_children::Relation::Predicate2.def(),
super::predicate_children::Relation::Predicate1.def(),
]
}
}

impl ActiveModelBehavior for ActiveModel {}
6 changes: 5 additions & 1 deletion optd-persistent/src/entities/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

pub use super::attribute::Entity as Attribute;
pub use super::attribute_constraint_junction::Entity as AttributeConstraintJunction;
Expand All @@ -18,6 +18,10 @@ pub use super::physical_expression::Entity as PhysicalExpression;
pub use super::physical_expression_to_statistic_junction::Entity as PhysicalExpressionToStatisticJunction;
pub use super::physical_property::Entity as PhysicalProperty;
pub use super::plan_cost::Entity as PlanCost;
pub use super::predicate::Entity as Predicate;
pub use super::predicate_children::Entity as PredicateChildren;
pub use super::predicate_logical_expression_junction::Entity as PredicateLogicalExpressionJunction;
pub use super::predicate_physical_expression_junction::Entity as PredicatePhysicalExpressionJunction;
pub use super::statistic::Entity as Statistic;
pub use super::statistic_to_attribute_junction::Entity as StatisticToAttributeJunction;
pub use super::table_metadata::Entity as TableMetadata;
Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/statistic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/table_metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/trigger.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
2 changes: 1 addition & 1 deletion optd-persistent/src/entities/versioned_statistic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.0
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1

use sea_orm::entity::prelude::*;

Expand Down
10 changes: 5 additions & 5 deletions optd-persistent/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ async fn basic_demo() {
group_id: group.id.clone(),
fingerprint: ActiveValue::Set(42), // Example fingerprint
variant_tag: ActiveValue::Set(1), // Example variant tag
data: ActiveValue::Set(json!({ // Example operator
"type": "Scan",
"table": "lineitem",
"predicate": "l_quantity < 10",
})),
// data: ActiveValue::Set(json!({ // Example operator
// "type": "Scan",
// "table": "lineitem",
// "predicate": "l_quantity < 10",
// })),
..Default::default()
}
.save(&db)
Expand Down
Loading
Loading