Skip to content

Commit

Permalink
Merge branch 'sarvesh/infra' of https://github.com/cmu-db/optd into s…
Browse files Browse the repository at this point in the history
…arvesh/infra
  • Loading branch information
SarveshOO7 committed Jan 28, 2025
2 parents 1cf2c82 + 54f6f19 commit 635692f
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 21 deletions.
16 changes: 8 additions & 8 deletions infra/src/types/operator/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ pub enum LogicalOperator<Link> {

/// TODO Add docs.
pub struct LogicalScanOperator<Link> {

Check warning on line 26 in infra/src/types/operator/logical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/logical.rs#L26

warning: struct `LogicalScanOperator` is never constructed --> infra/src/types/operator/logical.rs:26:12 | 26 | pub struct LogicalScanOperator<Link> { | ^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/logical.rs:26:12:w:warning: struct `LogicalScanOperator` is never constructed
  --> infra/src/types/operator/logical.rs:26:12
   |
26 | pub struct LogicalScanOperator<Link> {
   |            ^^^^^^^^^^^^^^^^^^^


__END__
table_name: String,
predicate: Link,
pub table_name: String,
pub predicate: Link,
}

/// TODO Add docs.
pub struct LogicalFilterOperator<Link> {

Check warning on line 32 in infra/src/types/operator/logical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/logical.rs#L32

warning: struct `LogicalFilterOperator` is never constructed --> infra/src/types/operator/logical.rs:32:12 | 32 | pub struct LogicalFilterOperator<Link> { | ^^^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/logical.rs:32:12:w:warning: struct `LogicalFilterOperator` is never constructed
  --> infra/src/types/operator/logical.rs:32:12
   |
32 | pub struct LogicalFilterOperator<Link> {
   |            ^^^^^^^^^^^^^^^^^^^^^


__END__
child: Link,
predicate: Link,
pub child: Link,
pub predicate: Link,
}

/// TODO Add docs.
pub struct LogicalJoinOperator<Link> {

Check warning on line 38 in infra/src/types/operator/logical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/logical.rs#L38

warning: struct `LogicalJoinOperator` is never constructed --> infra/src/types/operator/logical.rs:38:12 | 38 | pub struct LogicalJoinOperator<Link> { | ^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/logical.rs:38:12:w:warning: struct `LogicalJoinOperator` is never constructed
  --> infra/src/types/operator/logical.rs:38:12
   |
38 | pub struct LogicalJoinOperator<Link> {
   |            ^^^^^^^^^^^^^^^^^^^


__END__
join_type: (),
left: Link,
right: Link,
condition: Link,
pub join_type: (),
pub left: Link,
pub right: Link,
pub condition: Link,
}
20 changes: 10 additions & 10 deletions infra/src/types/operator/physical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@
/// [`PartialLogicalPlan`]: crate::plan::partial_logical_plan::PartialLogicalPlan
/// [`PartialPhysicalPlan`]: crate::plan::partial_physical_plan::PartialPhysicalPlan
pub enum PhysicalOperator<Link> {

Check warning on line 20 in infra/src/types/operator/physical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/physical.rs#L20

warning: enum `PhysicalOperator` is never used --> infra/src/types/operator/physical.rs:20:10 | 20 | pub enum PhysicalOperator<Link> { | ^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/physical.rs:20:10:w:warning: enum `PhysicalOperator` is never used
  --> infra/src/types/operator/physical.rs:20:10
   |
20 | pub enum PhysicalOperator<Link> {
   |          ^^^^^^^^^^^^^^^^


__END__
Scan(TableScanOperator<Link>),
TableScan(TableScanOperator<Link>),
Filter(PhysicalFilterOperator<Link>),
Join(HashJoinOperator<Link>),
HashJoin(HashJoinOperator<Link>),
}

/// TODO Add docs.
pub struct TableScanOperator<Link> {

Check warning on line 27 in infra/src/types/operator/physical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/physical.rs#L27

warning: struct `TableScanOperator` is never constructed --> infra/src/types/operator/physical.rs:27:12 | 27 | pub struct TableScanOperator<Link> { | ^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/physical.rs:27:12:w:warning: struct `TableScanOperator` is never constructed
  --> infra/src/types/operator/physical.rs:27:12
   |
27 | pub struct TableScanOperator<Link> {
   |            ^^^^^^^^^^^^^^^^^


__END__
table_name: String,
predicate: Link,
pub table_name: String,
pub predicate: Link,
}

/// TODO Add docs.
pub struct PhysicalFilterOperator<Link> {

Check warning on line 33 in infra/src/types/operator/physical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/physical.rs#L33

warning: struct `PhysicalFilterOperator` is never constructed --> infra/src/types/operator/physical.rs:33:12 | 33 | pub struct PhysicalFilterOperator<Link> { | ^^^^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/physical.rs:33:12:w:warning: struct `PhysicalFilterOperator` is never constructed
  --> infra/src/types/operator/physical.rs:33:12
   |
33 | pub struct PhysicalFilterOperator<Link> {
   |            ^^^^^^^^^^^^^^^^^^^^^^


__END__
child: Link,
predicate: Link,
pub child: Link,
pub predicate: Link,
}

/// TODO Add docs.
pub struct HashJoinOperator<Link> {

Check warning on line 39 in infra/src/types/operator/physical.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/operator/physical.rs#L39

warning: struct `HashJoinOperator` is never constructed --> infra/src/types/operator/physical.rs:39:12 | 39 | pub struct HashJoinOperator<Link> { | ^^^^^^^^^^^^^^^^
Raw output
infra/src/types/operator/physical.rs:39:12:w:warning: struct `HashJoinOperator` is never constructed
  --> infra/src/types/operator/physical.rs:39:12
   |
39 | pub struct HashJoinOperator<Link> {
   |            ^^^^^^^^^^^^^^^^


__END__
join_type: (),
left: Link,
right: Link,
condition: Link,
pub join_type: (),
pub left: Link,
pub right: Link,
pub condition: Link,
}
2 changes: 1 addition & 1 deletion infra/src/types/plan/logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::sync::Arc;
/// operator).
#[derive(Clone)]
pub struct LogicalPlan {

Check warning on line 15 in infra/src/types/plan/logical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/logical_plan.rs#L15

warning: struct `LogicalPlan` is never constructed --> infra/src/types/plan/logical_plan.rs:15:12 | 15 | pub struct LogicalPlan { | ^^^^^^^^^^^ | = note: `LogicalPlan` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
Raw output
infra/src/types/plan/logical_plan.rs:15:12:w:warning: struct `LogicalPlan` is never constructed
  --> infra/src/types/plan/logical_plan.rs:15:12
   |
15 | pub struct LogicalPlan {
   |            ^^^^^^^^^^^
   |
   = note: `LogicalPlan` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis


__END__
root: Arc<LogicalOperator<LogicalLink>>,
pub root: Arc<LogicalOperator<LogicalLink>>,
}

/// A link in a [`LogicalPlan`] to a node.
Expand Down
85 changes: 83 additions & 2 deletions infra/src/types/plan/physical_plan.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
use crate::types::operator::{
logical::LogicalOperator, physical::PhysicalOperator, ScalarOperator,
logical::LogicalOperator,

Check warning on line 2 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L2

warning: unused import: `logical::LogicalOperator` --> infra/src/types/plan/physical_plan.rs:2:5 | 2 | logical::LogicalOperator, | ^^^^^^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/plan/physical_plan.rs:2:5:w:warning: unused import: `logical::LogicalOperator`
 --> infra/src/types/plan/physical_plan.rs:2:5
  |
2 |     logical::LogicalOperator,
  |     ^^^^^^^^^^^^^^^^^^^^^^^^


__END__
physical::{HashJoinOperator, PhysicalFilterOperator, PhysicalOperator, TableScanOperator},
ScalarOperator,
};
use datafusion::{
common::{arrow::datatypes::Schema, JoinType}, datasource::physical_plan::{CsvExecBuilder, FileScanConfig}, execution::object_store::ObjectStoreUrl, physical_plan::{
expressions::NoOp,
filter::FilterExec,
joins::{HashJoinExec, PartitionMode},
ExecutionPlan,
}
};
use std::sync::Arc;

/// TODO Add docs.
#[derive(Clone)]
pub struct PhysicalPlan {

Check warning on line 18 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L18

warning: struct `PhysicalPlan` is never constructed --> infra/src/types/plan/physical_plan.rs:18:12 | 18 | pub struct PhysicalPlan { | ^^^^^^^^^^^^ | = note: `PhysicalPlan` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
Raw output
infra/src/types/plan/physical_plan.rs:18:12:w:warning: struct `PhysicalPlan` is never constructed
  --> infra/src/types/plan/physical_plan.rs:18:12
   |
18 | pub struct PhysicalPlan {
   |            ^^^^^^^^^^^^
   |
   = note: `PhysicalPlan` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis


__END__
root: Arc<PhysicalOperator<PhysicalLink>>,
pub root: Arc<PhysicalOperator<PhysicalLink>>,
}

/// TODO This is hacky prototype code, DO NOT USE!
impl PhysicalPlan {

Check warning on line 23 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L23

warning: method `as_datafusion_execution_plan` is never used --> infra/src/types/plan/physical_plan.rs:24:8 | 23 | impl PhysicalPlan { | ----------------- method in this implementation 24 | fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/plan/physical_plan.rs:23:1:w:warning: method `as_datafusion_execution_plan` is never used
  --> infra/src/types/plan/physical_plan.rs:24:8
   |
23 | impl PhysicalPlan {
   | ----------------- method in this implementation
24 |     fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> {
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


__END__
fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> {
self.root.as_datafusion_execution_plan()
}
}

/// TODO Add docs.
Expand All @@ -21,3 +38,67 @@ pub enum PhysicalLink {
pub enum ScalarLink {

Check warning on line 38 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L38

warning: enum `ScalarLink` is never used --> infra/src/types/plan/physical_plan.rs:38:10 | 38 | pub enum ScalarLink { | ^^^^^^^^^^ | = note: `ScalarLink` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
Raw output
infra/src/types/plan/physical_plan.rs:38:10:w:warning: enum `ScalarLink` is never used
  --> infra/src/types/plan/physical_plan.rs:38:10
   |
38 | pub enum ScalarLink {
   |          ^^^^^^^^^^
   |
   = note: `ScalarLink` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis


__END__
ScalarNode(Arc<ScalarOperator<ScalarLink>>),
}

/// TODO This is hacky prototype code, DO NOT USE!
impl PhysicalOperator<PhysicalLink> {

Check warning on line 43 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L43

warning: method `as_datafusion_execution_plan` is never used --> infra/src/types/plan/physical_plan.rs:44:8 | 43 | impl PhysicalOperator<PhysicalLink> { | ----------------------------------- method in this implementation 44 | fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Raw output
infra/src/types/plan/physical_plan.rs:43:1:w:warning: method `as_datafusion_execution_plan` is never used
  --> infra/src/types/plan/physical_plan.rs:44:8
   |
43 | impl PhysicalOperator<PhysicalLink> {
   | ----------------------------------- method in this implementation
44 |     fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> {
   |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^


__END__
fn as_datafusion_execution_plan(&self) -> Arc<dyn ExecutionPlan> {
match self {
PhysicalOperator::TableScan(TableScanOperator {
table_name,

Check warning on line 47 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L47

warning: unused variable: `table_name` --> infra/src/types/plan/physical_plan.rs:47:17 | 47 | table_name, | ^^^^^^^^^^ help: try ignoring the field: `table_name: _`
Raw output
infra/src/types/plan/physical_plan.rs:47:17:w:warning: unused variable: `table_name`
  --> infra/src/types/plan/physical_plan.rs:47:17
   |
47 |                 table_name,
   |                 ^^^^^^^^^^ help: try ignoring the field: `table_name: _`


__END__
predicate,

Check warning on line 48 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L48

warning: unused variable: `predicate` --> infra/src/types/plan/physical_plan.rs:48:17 | 48 | predicate, | ^^^^^^^^^ help: try ignoring the field: `predicate: _`
Raw output
infra/src/types/plan/physical_plan.rs:48:17:w:warning: unused variable: `predicate`
  --> infra/src/types/plan/physical_plan.rs:48:17
   |
48 |                 predicate,
   |                 ^^^^^^^^^ help: try ignoring the field: `predicate: _`


__END__
}) => {
let object_store_url = ObjectStoreUrl::local_filesystem();
let schema = Arc::new(Schema::empty()); // TODO FIX THIS!
let file_scan_config = FileScanConfig::new(object_store_url, schema);

Arc::new(CsvExecBuilder::new(file_scan_config).build())
}
PhysicalOperator::Filter(PhysicalFilterOperator { child, predicate }) => {

Check warning on line 56 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L56

warning: unused variable: `predicate` --> infra/src/types/plan/physical_plan.rs:56:70 | 56 | PhysicalOperator::Filter(PhysicalFilterOperator { child, predicate }) => { | ^^^^^^^^^ help: try ignoring the field: `predicate: _`
Raw output
infra/src/types/plan/physical_plan.rs:56:70:w:warning: unused variable: `predicate`
  --> infra/src/types/plan/physical_plan.rs:56:70
   |
56 |             PhysicalOperator::Filter(PhysicalFilterOperator { child, predicate }) => {
   |                                                                      ^^^^^^^^^ help: try ignoring the field: `predicate: _`


__END__
let PhysicalLink::PhysicalNode(child_operator) = child else {
unimplemented!("encountered a scalar operator");
};

let predicate_expr = Arc::new(NoOp {}); // TODO FIX THIS!
let child_plan = child_operator.as_datafusion_execution_plan();

Arc::new(FilterExec::try_new(predicate_expr, child_plan).unwrap())
}
PhysicalOperator::HashJoin(HashJoinOperator {
join_type,

Check warning on line 67 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L67

warning: unused variable: `join_type` --> infra/src/types/plan/physical_plan.rs:67:17 | 67 | join_type, | ^^^^^^^^^ help: try ignoring the field: `join_type: _`
Raw output
infra/src/types/plan/physical_plan.rs:67:17:w:warning: unused variable: `join_type`
  --> infra/src/types/plan/physical_plan.rs:67:17
   |
67 |                 join_type,
   |                 ^^^^^^^^^ help: try ignoring the field: `join_type: _`


__END__
left,
right,
condition,

Check warning on line 70 in infra/src/types/plan/physical_plan.rs

View workflow job for this annotation

GitHub Actions / clippy

[clippy] infra/src/types/plan/physical_plan.rs#L70

warning: unused variable: `condition` --> infra/src/types/plan/physical_plan.rs:70:17 | 70 | condition, | ^^^^^^^^^ help: try ignoring the field: `condition: _`
Raw output
infra/src/types/plan/physical_plan.rs:70:17:w:warning: unused variable: `condition`
  --> infra/src/types/plan/physical_plan.rs:70:17
   |
70 |                 condition,
   |                 ^^^^^^^^^ help: try ignoring the field: `condition: _`


__END__
}) => {
let PhysicalLink::PhysicalNode(left_operator) = left else {
unimplemented!("encountered a scalar operator");
};
let PhysicalLink::PhysicalNode(right_operator) = right else {
unimplemented!("encountered a scalar operator");
};

let left_plan = left_operator.as_datafusion_execution_plan();
let right_plan = right_operator.as_datafusion_execution_plan();
let condition_on = vec![]; // TODO FIX THIS!
let join_filter = None;
let join_type = JoinType::Inner;
let projection = None;
let partition_mode = PartitionMode::CollectLeft;
let null_equals_null = true;

Arc::new(
HashJoinExec::try_new(
left_plan,
right_plan,
condition_on,
join_filter,
&join_type,
projection,
partition_mode,
null_equals_null,
)
.unwrap(),
)
}
}
}
}

0 comments on commit 635692f

Please sign in to comment.