From bea3b3062548145c11dffff0e473b12ff2b76e6d Mon Sep 17 00:00:00 2001 From: NGA-TRAN Date: Tue, 14 Nov 2023 15:59:11 -0500 Subject: [PATCH] test: add count distinct group by date_bin --- .../sqllogictest/test_files/groupby.slt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/datafusion/sqllogictest/test_files/groupby.slt b/datafusion/sqllogictest/test_files/groupby.slt index 105f11f21628..1af2e9e825fd 100644 --- a/datafusion/sqllogictest/test_files/groupby.slt +++ b/datafusion/sqllogictest/test_files/groupby.slt @@ -2278,6 +2278,27 @@ CREATE TABLE exchange_rates ( (3, '2022-01-02 12:00:00'::timestamp, 'TRY', 'USD', 0.11), (4, '2022-01-03 10:00:00'::timestamp, 'EUR', 'USD', 1.12) +# test count and count distinct group by date_bin/date_part +query error +select date_bin(interval '1 minute', ts) as bin, count(distinct currency_from) as count from exchange_rates group by bin; + +query error +select date_part('year', ts) as year, count(distinct currency_from) as count from exchange_rates group by year; + +query PI +select date_bin(interval '1 minute', ts) as bin, count(currency_from) as count from exchange_rates group by bin; +---- +2022-01-01T06:00:00 1 +2022-01-01T08:00:00 1 +2022-01-01T11:30:00 1 +2022-01-02T12:00:00 1 +2022-01-03T10:00:00 1 + +query RI +select date_part('year', ts) as year, count(currency_from) as count from exchange_rates group by year; +---- +2022 5 + # test_ordering_sensitive_aggregation # ordering sensitive requirement should add a SortExec in the final plan. To satisfy amount ASC # in the aggregation