You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ja...@apache.org on 2023/01/26 13:02:28 UTC
[arrow-datafusion] branch master updated: Minor: Move some aggregate error tests to sqllogictests (#5055)
This is an automated email from the ASF dual-hosted git repository.
jakevin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git
The following commit(s) were added to refs/heads/master by this push:
new be4586858 Minor: Move some aggregate error tests to sqllogictests (#5055)
be4586858 is described below
commit be4586858306ebbc47848243fe488dd4316e3f2f
Author: Andrew Lamb <an...@nerdnetworks.org>
AuthorDate: Thu Jan 26 14:02:21 2023 +0100
Minor: Move some aggregate error tests to sqllogictests (#5055)
* Minor: Move some aggregate error tests to sqllogictests
* Remove redundant test
---
datafusion/core/tests/sql/aggregates.rs | 114 ---------------------
.../tests/sqllogictests/test_files/aggregate.slt | 35 +++++++
2 files changed, 35 insertions(+), 114 deletions(-)
diff --git a/datafusion/core/tests/sql/aggregates.rs b/datafusion/core/tests/sql/aggregates.rs
index 47bbffaef..cea7edf74 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.slt
index 7dfd18365..2b280a5c8 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 CSV
WITH HEADER ROW
LOCATION '../../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