Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
desmondcheongzx committed Nov 23, 2024
1 parent 4ef4998 commit b3e4c3a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/daft-catalog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mod tests {
#[test]
fn test_register_and_unregister_named_table() {
let mut catalog = DaftMetaCatalog::new_from_env();
let plan = LogicalPlanBuilder::new(mock_plan(), None, None);
let plan = LogicalPlanBuilder::from(mock_plan());

// Register a table
assert!(catalog
Expand All @@ -198,7 +198,7 @@ mod tests {
#[test]
fn test_read_registered_table() {
let mut catalog = DaftMetaCatalog::new_from_env();
let plan = LogicalPlanBuilder::new(mock_plan(), None, None);
let plan = LogicalPlanBuilder::from(mock_plan());

catalog.register_named_table("test_table", plan).unwrap();

Expand Down
1 change: 1 addition & 0 deletions src/daft-local-execution/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ pub fn physical_plan_to_pipeline(
left_stats.approx_stats.upper_bound_bytes
<= right_stats.approx_stats.upper_bound_bytes
}
// If stats are not available, we fall back and build on the left.
_ => true,
};

Expand Down
4 changes: 2 additions & 2 deletions src/daft-logical-plan/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl LogicalPlanBuilder {
));
let logical_plan: LogicalPlan = ops::Source::new(schema, source_info.into()).into();

Ok(Self::new(logical_plan.into(), None, None))
Ok(Self::from(Arc::new(logical_plan)))
}

pub fn table_scan(
Expand Down Expand Up @@ -204,7 +204,7 @@ impl LogicalPlanBuilder {
schema_with_generated_fields
};
let logical_plan: LogicalPlan = ops::Source::new(output_schema, source_info.into()).into();
Ok(Self::new(logical_plan.into(), None, None))
Ok(Self::from(Arc::new(logical_plan)))
}

pub fn select(&self, to_select: Vec<ExprRef>) -> DaftResult<Self> {
Expand Down
10 changes: 5 additions & 5 deletions src/daft-logical-plan/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ mod test {
#[test]
// create a random, complex plan and check if it can be displayed as expected
fn test_mermaid_display() -> DaftResult<()> {
let subplan = LogicalPlanBuilder::new(plan_1(), None, None)
let subplan = LogicalPlanBuilder::from(plan_1())
.filter(col("id").eq(lit(1)))?
.build();

let subplan2 = LogicalPlanBuilder::new(plan_2(), None, None)
let subplan2 = LogicalPlanBuilder::from(plan_2())
.filter(
startswith(col("last_name"), lit("S")).and(endswith(col("last_name"), lit("n"))),
)?
Expand Down Expand Up @@ -159,11 +159,11 @@ Project1 --> Limit0
#[test]
// create a random, complex plan and check if it can be displayed as expected
fn test_mermaid_display_simple() -> DaftResult<()> {
let subplan = LogicalPlanBuilder::new(plan_1(), None, None)
let subplan = LogicalPlanBuilder::from(plan_1())
.filter(col("id").eq(lit(1)))?
.build();

let subplan2 = LogicalPlanBuilder::new(plan_2(), None, None)
let subplan2 = LogicalPlanBuilder::from(plan_2())
.filter(
startswith(col("last_name"), lit("S")).and(endswith(col("last_name"), lit("n"))),
)?
Expand All @@ -173,7 +173,7 @@ Project1 --> Limit0
.sort(vec![col("last_name")], vec![false], vec![false])?
.build();

let plan = LogicalPlanBuilder::new(subplan, None, None)
let plan = LogicalPlanBuilder::from(subplan)
.join_with_null_safe_equal(
subplan2,
vec![col("id")],
Expand Down
1 change: 1 addition & 0 deletions src/daft-logical-plan/src/ops/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl Source {
}
}

// Helper function that converts ScanOperatorRef inside a the Source node's PhysicalScanInfo into scan tasks.
pub(crate) fn build_materialized_scan_source(
mut self,
execution_config: Option<&DaftExecutionConfig>,
Expand Down
20 changes: 10 additions & 10 deletions src/daft-sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ mod tests {
let sql = "select test as a from tbl1";
let plan = planner.plan_sql(sql).unwrap();

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.select(vec![col("test").alias("a")])
.unwrap()
.build();
Expand All @@ -203,7 +203,7 @@ mod tests {
let sql = "select test as a from tbl1 where test = 'a'";
let plan = planner.plan_sql(sql)?;

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.filter(col("test").eq(lit("a")))?
.select(vec![col("test").alias("a")])?
.build();
Expand All @@ -216,7 +216,7 @@ mod tests {
let sql = "select test as a from tbl1 limit 10";
let plan = planner.plan_sql(sql)?;

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.select(vec![col("test").alias("a")])?
.limit(10, true)?
.build();
Expand All @@ -230,7 +230,7 @@ mod tests {
let sql = "select utf8 from tbl1 order by utf8 desc";
let plan = planner.plan_sql(sql)?;

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.select(vec![col("utf8")])?
.sort(vec![col("utf8")], vec![true], vec![true])?
.build();
Expand All @@ -241,7 +241,7 @@ mod tests {

#[rstest]
fn test_cast(mut planner: SQLPlanner, tbl_1: LogicalPlanRef) -> SQLPlannerResult<()> {
let builder = LogicalPlanBuilder::new(tbl_1, None, None);
let builder = LogicalPlanBuilder::from(tbl_1);
let cases = vec![
(
"select bool::text from tbl1",
Expand Down Expand Up @@ -285,7 +285,7 @@ mod tests {
if null_equals_null { "<=>" } else { "=" }
);
let plan = planner.plan_sql(&sql)?;
let expected = LogicalPlanBuilder::new(tbl_2, None, None)
let expected = LogicalPlanBuilder::from(tbl_2)
.join_with_null_safe_equal(
tbl_3,
vec![col("id")],
Expand All @@ -312,7 +312,7 @@ mod tests {
let sql = "select * from tbl2 join tbl3 on tbl2.id = tbl3.id and tbl2.val > 0";
let plan = planner.plan_sql(&sql)?;

let expected = LogicalPlanBuilder::new(tbl_2, None, None)
let expected = LogicalPlanBuilder::from(tbl_2)
.filter(col("val").gt(lit(0 as i64)))?
.join_with_null_safe_equal(
tbl_3,
Expand Down Expand Up @@ -394,7 +394,7 @@ mod tests {
let sql = "select max(i32) from tbl1";
let plan = planner.plan_sql(sql)?;

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.aggregate(vec![col("i32").max()], vec![])?
.select(vec![col("i32")])?
.build();
Expand Down Expand Up @@ -469,15 +469,15 @@ mod tests {
field: Field::new("i32", DataType::Int32),
depth: 1,
}));
let subquery = LogicalPlanBuilder::new(tbl_2, None, None)
let subquery = LogicalPlanBuilder::from(tbl_2)
.filter(col("id").eq(outer_col))?
.aggregate(vec![col("id").max()], vec![])?
.select(vec![col("id")])?
.build();

let subquery = Arc::new(Expr::Subquery(Subquery { plan: subquery }));

let expected = LogicalPlanBuilder::new(tbl_1, None, None)
let expected = LogicalPlanBuilder::from(tbl_1)
.filter(col("i64").gt(subquery))?
.select(vec![col("utf8")])?
.build();
Expand Down

0 comments on commit b3e4c3a

Please sign in to comment.