Apache DataFusion SQL Query Engine
Minor: Move some aggregate error tests to sqllogictests (#5055)
Andrew Lambbe4586858306
diff --git a/datafusion/core/tests/sql/aggregates.rs b/datafusion/core/tests/sql/aggregates.rsindex 47bbffaefc..cea7edf749 100644--- a/datafusion/core/tests/sql/aggregates.rs+++ b/datafusion/core/tests/sql/aggregates.rs@@ -20,120 +20,6 @@ use datafusion::scalar::ScalarValue;use datafusion::test_util::scan_empty;use datafusion_common::cast::as_float64_array;-#[tokio::test]-#[ignore] // https://github.com/apache/arrow-datafusion/issues/3353-async fn csv_query_approx_count() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;- let sql = "SELECT approx_distinct(c9) count_c9, approx_distinct(cast(c9 as varchar)) count_c9_str FROM aggregate_test_100";- let actual = execute_to_batches(&ctx, sql).await;- let expected = vec![- "+----------+--------------+",- "| count_c9 | count_c9_str |",- "+----------+--------------+",- "| 100 | 99 |",- "+----------+--------------+",- ];- assert_batches_eq!(expected, &actual);- Ok(())-}--#[tokio::test]-async fn csv_query_approx_percentile_cont_with_weight() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;-- let results = plan_and_collect(- &ctx,- "SELECT approx_percentile_cont_with_weight(c1, c2, 0.95) FROM aggregate_test_100",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "Error during planning: The function ApproxPercentileContWithWeight does not support inputs of type Utf8.");-- let results = plan_and_collect(- &ctx,- "SELECT approx_percentile_cont_with_weight(c3, c1, 0.95) FROM aggregate_test_100",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "Error during planning: The weight argument for ApproxPercentileContWithWeight does not support inputs of type Utf8.");-- let results = plan_and_collect(- &ctx,- "SELECT approx_percentile_cont_with_weight(c3, c2, c1) FROM aggregate_test_100",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "Error during planning: The percentile argument for ApproxPercentileContWithWeight must be Float64, not Utf8.");-- Ok(())-}--#[tokio::test]-async fn csv_query_approx_percentile_cont_with_histogram_bins() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;-- let results = plan_and_collect(- &ctx,- "SELECT c1, approx_percentile_cont(c3, 0.95, -1000) AS c3_p95 FROM aggregate_test_100 GROUP BY 1 ORDER BY 1",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "This feature is not implemented: Tdigest max_size value for 'APPROX_PERCENTILE_CONT' must be UInt > 0 literal (got data type Int64).");-- let results = plan_and_collect(- &ctx,- "SELECT approx_percentile_cont(c3, 0.95, c1) FROM aggregate_test_100",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "Error during planning: The percentile sample points count for ApproxPercentileCont must be integer, not Utf8.");-- let results = plan_and_collect(- &ctx,- "SELECT approx_percentile_cont(c3, 0.95, 111.1) FROM aggregate_test_100",- )- .await- .unwrap_err();- assert_eq!(results.to_string(), "Error during planning: The percentile sample points count for ApproxPercentileCont must be integer, not Float64.");-- Ok(())-}--#[tokio::test]-async fn csv_query_array_agg_unsupported() -> Result<()> {- let ctx = SessionContext::new();- register_aggregate_csv(&ctx).await?;-- let results = plan_and_collect(- &ctx,- "SELECT array_agg(c13 ORDER BY c1) FROM aggregate_test_100",- )- .await- .unwrap_err();-- assert_eq!(- results.to_string(),- "This feature is not implemented: ORDER BY not supported in ARRAY_AGG: c1"- );-- let results = plan_and_collect(- &ctx,- "SELECT array_agg(c13 LIMIT 1) FROM aggregate_test_100",- )- .await- .unwrap_err();-- assert_eq!(- results.to_string(),- "This feature is not implemented: LIMIT not supported in ARRAY_AGG: 1"- );-- Ok(())-}-#[tokio::test]async fn csv_query_array_agg_distinct() -> Result<()> {let ctx = SessionContext::new();diff --git a/datafusion/core/tests/sqllogictests/test_files/aggregate.slt b/datafusion/core/tests/sqllogictests/test_files/aggregate.sltindex 7dfd183650..2b280a5c85 100644--- a/datafusion/core/tests/sqllogictests/test_files/aggregate.slt+++ b/datafusion/core/tests/sqllogictests/test_files/aggregate.slt@@ -36,6 +36,41 @@ STORED AS CSVWITH HEADER ROWLOCATION '../../testing/data/csv/aggregate_test_100.csv'+#######+# Error tests+#######++# https://github.com/apache/arrow-datafusion/issues/3353+statement error Aggregations require unique expression names+SELECT approx_distinct(c9) count_c9, approx_distinct(cast(c9 as varchar)) count_c9_str FROM aggregate_test_100++# csv_query_approx_percentile_cont_with_weight+statement error Error during planning: The function ApproxPercentileContWithWeight does not support inputs of type Utf8.+SELECT approx_percentile_cont_with_weight(c1, c2, 0.95) FROM aggregate_test_100++statement error Error during planning: The weight argument for ApproxPercentileContWithWeight does not support inputs of type Utf8+SELECT approx_percentile_cont_with_weight(c3, c1, 0.95) FROM aggregate_test_100++statement error Error during planning: The percentile argument for ApproxPercentileContWithWeight must be Float64, not Utf8.+SELECT approx_percentile_cont_with_weight(c3, c2, c1) FROM aggregate_test_100++# csv_query_approx_percentile_cont_with_histogram_bins+statement error This feature is not implemented: Tdigest max_size value for 'APPROX_PERCENTILE_CONT' must be UInt > 0 literal \(got data type Int64\).+SELECT c1, approx_percentile_cont(c3, 0.95, -1000) AS c3_p95 FROM aggregate_test_100 GROUP BY 1 ORDER BY 1++statement error Error during planning: The percentile sample points count for ApproxPercentileCont must be integer, not Utf8.+SELECT approx_percentile_cont(c3, 0.95, c1) FROM aggregate_test_100++statement error Error during planning: The percentile sample points count for ApproxPercentileCont must be integer, not Float64.+SELECT approx_percentile_cont(c3, 0.95, 111.1) FROM aggregate_test_100++# csv_query_array_agg_unsupported+statement error This feature is not implemented: ORDER BY not supported in ARRAY_AGG: c1+SELECT array_agg(c13 ORDER BY c1) FROM aggregate_test_100++statement error This feature is not implemented: LIMIT not supported in ARRAY_AGG: 1+SELECT array_agg(c13 LIMIT 1) FROM aggregate_test_100+# FIX: custom absolute values# csv_query_avg_multi_batch