Skip to content

Commit

Permalink
Optimization test fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkzinzow committed Sep 12, 2023
1 parent ea35aa1 commit e140c81
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/daft-plan/src/logical_ops/agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Aggregate {
));
if !self.groupby.is_empty() {
res.push(format!(
"Group by = {:?}",
"Group by = {}",
self.groupby
.iter()
.map(|e| e.to_string())
Expand Down
7 changes: 5 additions & 2 deletions src/daft-plan/src/logical_ops/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ impl Source {
file_format_config,
storage_config,
}) => {
res.push(format!("Source: {:?}", file_format_config.var_name()));
res.push(format!("File paths = {:?}", file_infos.file_paths));
res.push(format!("Source: {}", file_format_config.var_name()));
res.push(format!(
"File paths = [{}]",
file_infos.file_paths.join(", ")
));
res.push(format!("File schema = {}", source_schema.short_string()));
res.push(format!("Format-specific config = {:?}", file_format_config));
res.push(format!("Storage config = {:?}", storage_config));
Expand Down
2 changes: 1 addition & 1 deletion src/daft-plan/src/optimization/optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ mod tests {
let expected = "\
Filter: [[[col(a) < lit(2)] | lit(false)] | lit(false)] & lit(true)\
\n Project: col(a) + lit(3) AS c, col(a) + lit(1), col(a) + lit(2) AS b\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64)";
assert_eq!(opt_plan.repr_indent(), expected);
Ok(())
}
Expand Down
12 changes: 6 additions & 6 deletions src/daft-plan/src/optimization/rules/drop_repartition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ mod tests {
.build();
let expected = "\
Repartition: Scheme = Hash, Number of partitions = 5, Partition by = col(a)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -130,7 +130,7 @@ mod tests {
.repartition(1, vec![col("a")], PartitionScheme::Hash)?
.build();
let expected = "\
Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -151,7 +151,7 @@ mod tests {
let expected = "\
Filter: col(a) < lit(2)\
\n Repartition: Scheme = Hash, Number of partitions = 10, Partition by = col(a)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -173,9 +173,9 @@ mod tests {
.repartition(10, vec![col("b")], PartitionScheme::Hash)?
.build();
let expected = "\
Aggregation: [Sum(Column(\"a\"))], Group by = [Column(\"b\")], Output schema = b (Int64), a (Int64)\
Aggregation: sum(col(a)), Group by = col(b), Output schema = b (Int64), a (Int64)\
\n Repartition: Scheme = Hash, Number of partitions = 10, Partition by = col(a)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Int64)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Int64)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -195,7 +195,7 @@ mod tests {
Repartition: Scheme = Range, Number of partitions = 10, Partition by = col(a)\
\n Sort: Sort by = (col(a), descending)\
\n Repartition: Scheme = Hash, Number of partitions = 10, Partition by = col(a)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand Down
32 changes: 16 additions & 16 deletions src/daft-plan/src/optimization/rules/push_down_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ mod tests {
.build();
let expected = "\
Filter: [col(b) == lit(\"foo\")] & [col(a) < lit(2)]\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -279,7 +279,7 @@ mod tests {
let expected = "\
Project: col(a)\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -297,7 +297,7 @@ mod tests {
let expected = "\
Project: col(a), col(b)\
\n Filter: [col(a) < lit(2)] & [col(b) == lit(\"foo\")]\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -317,7 +317,7 @@ mod tests {
let expected = "\
Filter: col(a) < lit(2)\
\n Project: col(a) + lit(1)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -338,7 +338,7 @@ mod tests {
let expected = "\
Project: col(a) + lit(1)\
\n Filter: [col(a) + lit(1)] < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -356,7 +356,7 @@ mod tests {
let expected = "\
Sort: Sort by = (col(a), descending)\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
// TODO(Clark): For tests in which we only care about reordering of operators, maybe switch to a form that leverages the single-node display?
// let expected = format!("{sort}\n {filter}\n {source}");
assert_optimized_plan_eq(plan, expected)?;
Expand All @@ -376,7 +376,7 @@ mod tests {
let expected = "\
Repartition: Scheme = Hash, Number of partitions = 1, Partition by = col(a)\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -394,7 +394,7 @@ mod tests {
let expected = "\
Coalesce: To = 1\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -413,9 +413,9 @@ mod tests {
let expected = "\
Concat\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -441,8 +441,8 @@ mod tests {
let expected = "\
Join: Type = Inner, On = col(b), Output schema = a (Int64), b (Utf8), c (Float64)\
\n Filter: col(a) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Source: \"Json\", File paths = /foo, File schema = b (Utf8), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Utf8), c (Float64)";
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Source: Json, File paths = [/foo], File schema = b (Utf8), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Utf8), c (Float64)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -467,9 +467,9 @@ mod tests {
.build();
let expected = "\
Join: Type = Inner, On = col(b), Output schema = a (Int64), b (Utf8), c (Float64)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Utf8), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Utf8)\
\n Filter: col(c) < lit(2.0)\
\n Source: \"Json\", File paths = /foo, File schema = b (Utf8), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Utf8), c (Float64)";
\n Source: Json, File paths = [/foo], File schema = b (Utf8), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Utf8), c (Float64)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand All @@ -493,9 +493,9 @@ mod tests {
let expected = "\
Join: Type = Inner, On = col(b), Output schema = a (Int64), b (Int64), c (Float64)\
\n Filter: col(b) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = a (Int64), b (Int64), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Int64), c (Float64)\
\n Source: Json, File paths = [/foo], File schema = a (Int64), b (Int64), c (Float64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = a (Int64), b (Int64), c (Float64)\
\n Filter: col(b) < lit(2)\
\n Source: \"Json\", File paths = /foo, File schema = b (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Int64)";
\n Source: Json, File paths = [/foo], File schema = b (Int64), Format-specific config = Json(JsonSourceConfig), Storage config = Native(NativeStorageConfig { io_config: None }), Output schema = b (Int64)";
assert_optimized_plan_eq(plan, expected)?;
Ok(())
}
Expand Down
Loading

0 comments on commit e140c81

Please sign in to comment.