Skip to content

Commit 1968a37

Browse files
committed
refactor: simplify run_snapshot_test function by removing unused parameter
1 parent 86db749 commit 1968a37

File tree

1 file changed

+7
-51
lines changed

1 file changed

+7
-51
lines changed

datafusion/core/tests/sql/aggregates.rs

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ impl TestData {
271271
/// run_complete_snapshot_test(&test_data, "SELECT * FROM t", @"expected output").await?;
272272
///
273273
/// // Multiple tests with different data
274-
/// let results = run_snapshot_test(&test_data, "SELECT * FROM t", false).await?;
274+
/// let results = run_snapshot_test(&test_data, "SELECT * FROM t").await?;
275275
/// assert_snapshot!(batches_to_string(&results), @"expected");
276276
/// ```
277277
async fn setup_test_contexts(
@@ -788,7 +788,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> {
788788

789789
// Test COUNT null exclusion with basic data
790790
let sql_count = "SELECT dict_null_keys, COUNT(value) as cnt FROM t GROUP BY dict_null_keys ORDER BY dict_null_keys NULLS FIRST";
791-
let results_count = run_snapshot_test(&test_data_basic, sql_count, false).await?;
791+
let results_count = run_snapshot_test(&test_data_basic, sql_count).await?;
792792

793793
assert_snapshot!(
794794
batches_to_string(&results_count),
@@ -805,7 +805,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> {
805805

806806
// Test SUM null handling with extended data
807807
let sql_sum = "SELECT dict_null_vals, SUM(value) as total FROM t GROUP BY dict_null_vals ORDER BY dict_null_vals NULLS FIRST";
808-
let results_sum = run_snapshot_test(&test_data_extended, sql_sum, false).await?;
808+
let results_sum = run_snapshot_test(&test_data_extended, sql_sum).await?;
809809

810810
assert_snapshot!(
811811
batches_to_string(&results_sum),
@@ -823,7 +823,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> {
823823

824824
// Test MIN null handling with min/max data
825825
let sql_min = "SELECT dict_null_keys, MIN(value) as minimum FROM t GROUP BY dict_null_keys ORDER BY dict_null_keys NULLS FIRST";
826-
let results_min = run_snapshot_test(&test_data_min_max, sql_min, false).await?;
826+
let results_min = run_snapshot_test(&test_data_min_max, sql_min).await?;
827827

828828
assert_snapshot!(
829829
batches_to_string(&results_min),
@@ -841,7 +841,7 @@ async fn test_aggregates_null_handling_comprehensive() -> Result<()> {
841841

842842
// Test MEDIAN null handling with median data
843843
let sql_median = "SELECT dict_null_vals, MEDIAN(value) as median_value FROM t GROUP BY dict_null_vals ORDER BY dict_null_vals NULLS FIRST";
844-
let results_median = run_snapshot_test(&test_data_median, sql_median, false).await?;
844+
let results_median = run_snapshot_test(&test_data_median, sql_median).await?;
845845

846846
assert_snapshot!(
847847
batches_to_string(&results_median),
@@ -867,7 +867,7 @@ async fn test_first_last_val_null_handling() -> Result<()> {
867867
// Test FIRST_VALUE and LAST_VALUE with window functions over groups
868868
let sql = "SELECT dict_null_keys, value, FIRST_VALUE(value) OVER (PARTITION BY dict_null_keys ORDER BY value NULLS FIRST) as first_val, LAST_VALUE(value) OVER (PARTITION BY dict_null_keys ORDER BY value NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) as last_val FROM t ORDER BY dict_null_keys NULLS FIRST, value NULLS FIRST";
869869

870-
let results_single = run_snapshot_test(&test_data, sql, false).await?;
870+
let results_single = run_snapshot_test(&test_data, sql).await?;
871871

872872
assert_snapshot!(batches_to_string(&results_single), @r"
873873
+----------------+-------+-----------+----------+
@@ -1729,56 +1729,12 @@ async fn test_median_distinct_with_fuzz_table_dict_nulls() -> Result<()> {
17291729

17301730
/// Helper function to run snapshot tests with consistent setup, execution, and assertion
17311731
/// This reduces the repetitive pattern of "setup data → SQL → assert_snapshot!"
1732-
async fn run_snapshot_test(
1733-
test_data: &TestData,
1734-
sql: &str,
1735-
_use_sorted_output: bool,
1736-
) -> Result<Vec<RecordBatch>> {
1732+
async fn run_snapshot_test(test_data: &TestData, sql: &str) -> Result<Vec<RecordBatch>> {
17371733
let (ctx_single, ctx_multi) = setup_test_contexts(test_data).await?;
17381734
let results = test_query_consistency(&ctx_single, &ctx_multi, sql).await?;
17391735
Ok(results)
17401736
}
17411737

1742-
/// Helper function for simpler snapshot tests that only need single-partition execution
1743-
#[allow(dead_code)]
1744-
async fn run_simple_snapshot_test(
1745-
ctx: &SessionContext,
1746-
sql: &str,
1747-
) -> Result<Vec<RecordBatch>> {
1748-
let df = ctx.sql(sql).await?;
1749-
let results = df.collect().await?;
1750-
Ok(results)
1751-
}
1752-
1753-
/// Helper function to run a complete snapshot test with TestData
1754-
/// This fully encapsulates the "setup data → SQL → assert_snapshot!" pattern
1755-
#[allow(dead_code)]
1756-
async fn run_complete_snapshot_test(
1757-
test_data: &TestData,
1758-
sql: &str,
1759-
expected_snapshot: &str,
1760-
) -> Result<()> {
1761-
let results = run_snapshot_test(test_data, sql, false).await?;
1762-
1763-
assert_snapshot!(batches_to_string(&results), expected_snapshot);
1764-
1765-
Ok(())
1766-
}
1767-
1768-
/// Helper function to run a complete snapshot test with sorted output
1769-
#[allow(dead_code)]
1770-
async fn run_complete_sorted_snapshot_test(
1771-
test_data: &TestData,
1772-
sql: &str,
1773-
expected_snapshot: &str,
1774-
) -> Result<()> {
1775-
let results = run_snapshot_test(test_data, sql, true).await?;
1776-
1777-
assert_snapshot!(batches_to_sort_string(&results), expected_snapshot);
1778-
1779-
Ok(())
1780-
}
1781-
17821738
/// Test data structure for fuzz table with timestamp and dictionary columns containing nulls
17831739
struct FuzzTimestampTestData {
17841740
schema: Arc<Schema>,

0 commit comments

Comments
 (0)