You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "korowa (via GitHub)" <gi...@apache.org> on 2023/03/13 17:49:13 UTC

[GitHub] [arrow-datafusion] korowa commented on a diff in pull request #5574: Minor: Port more aggregate tests to sqllogictests

korowa commented on code in PR #5574:
URL: https://github.com/apache/arrow-datafusion/pull/5574#discussion_r1134398743


##########
datafusion/core/tests/sqllogictests/test_files/aggregate.slt:
##########
@@ -1284,3 +1284,148 @@ NULL 2
 
 statement ok
 drop table the_nulls;
+
+# All supported timestamp types
+
+# "nanos" --> TimestampNanosecondArray
+# "micros" --> TimestampMicrosecondArray
+# "millis" --> TimestampMillisecondArray
+# "secs" --> TimestampSecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('2018-11-13T17:11:10.011375885995', 'Row 0'),
+ ('2011-12-13T11:13:10.12345', 'Row 1'),
+ (null, 'Row 2'),
+ ('2021-1-1T05:11:10.432', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Timestamp(Nanosecond, None)') as nanos,
+  arrow_cast(column1, 'Timestamp(Microsecond, None)') as micros,
+  arrow_cast(column1, 'Timestamp(Millisecond, None)') as millis,
+  arrow_cast(column1, 'Timestamp(Second, None)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query PPPPT
+select * from t;
+----
+2018-11-13T17:11:10.011375885 2018-11-13T17:11:10.011375 2018-11-13T17:11:10.011 2018-11-13T17:11:10 Row 0
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10 Row 1
+NULL NULL NULL NULL Row 2
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10 Row 3
+
+
+# aggregate_timestamps_sum() -> Result<()> {
+statement error Error during planning: The function Sum does not support inputs of type Timestamp\(Nanosecond, None\)
+SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t;
+
+query IIII
+SELECT count(nanos), count(micros), count(millis), count(secs) FROM t;
+----
+3 3 3 3
+
+
+# aggregate_timestamps_min
+query PPPP
+SELECT min(nanos), min(micros), min(millis), min(secs) FROM t;
+----
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10
+
+# aggregate_timestamps_max
+query PPPP
+SELECT max(nanos), max(micros), max(millis), max(secs) FROM t;
+----
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10
+
+
+
+# aggregate_timestamps_avg
+statement error Error during planning: The function Avg does not support inputs of type Timestamp\(Nanosecond, None\).
+SELECT avg(nanos), avg(micros), avg(millis), avg(secs) FROM t
+
+
+statement ok
+drop table t_source;
+
+statement ok
+drop table t;
+
+# All supported time types
+
+# Columns are named:
+# "nanos" --> Time64NanosecondArray
+# "micros" --> Time64MicrosecondArray
+# "millis" --> Time32MillisecondArray
+# "secs" --> Time32SecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('18:06:30.243620451', 'Row 0'),
+ ('20:08:28.161121654', 'Row 1'),
+ ('19:11:04.156423842', 'Row 2'),
+ ('21:06:28.247821084', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Time64(Nanosecond)') as nanos,
+  arrow_cast(column1, 'Time64(Microsecond)') as micros,
+  arrow_cast(column1, 'Time32(Millisecond)') as millis,
+  arrow_cast(column1, 'Time32(Second)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query DDDDT
+select * from t;
+----
+18:06:30.243620451 18:06:30.243620 18:06:30.243 18:06:30 Row 0
+20:08:28.161121654 20:08:28.161121 20:08:28.161 20:08:28 Row 1
+19:11:04.156423842 19:11:04.156423 19:11:04.156 19:11:04 Row 2
+21:06:28.247821084 21:06:28.247821 21:06:28.247 21:06:28 Row 3
+
+# aggregate_times_sum
+statement error DataFusion error: Error during planning: The function Sum does not support inputs of type Time64\(Nanosecond\).
+SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t
+
+# aggregate_times_count() -> Result<()>
+query IIII
+SELECT count(nanos), count(micros), count(millis), count(secs) FROM t
+----
+4 4 4 4
+
+
+# aggregate_times_min
+query DDDD
+SELECT min(nanos), min(micros), min(millis), min(secs) FROM t
+----
+18:06:30.243620451 18:06:30.243620 18:06:30.243 18:06:30
+
+# aggregate_times_max
+query DDDD
+SELECT max(nanos), max(micros), max(millis), max(secs) FROM t
+----
+21:06:28.247821084 21:06:28.247821 21:06:28.247 21:06:28
+
+
+# aggregate_times_avg

Review Comment:
   👍 



##########
datafusion/core/tests/sqllogictests/test_files/aggregate.slt:
##########
@@ -1284,3 +1284,148 @@ NULL 2
 
 statement ok
 drop table the_nulls;
+
+# All supported timestamp types
+
+# "nanos" --> TimestampNanosecondArray
+# "micros" --> TimestampMicrosecondArray
+# "millis" --> TimestampMillisecondArray
+# "secs" --> TimestampSecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('2018-11-13T17:11:10.011375885995', 'Row 0'),
+ ('2011-12-13T11:13:10.12345', 'Row 1'),
+ (null, 'Row 2'),
+ ('2021-1-1T05:11:10.432', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Timestamp(Nanosecond, None)') as nanos,
+  arrow_cast(column1, 'Timestamp(Microsecond, None)') as micros,
+  arrow_cast(column1, 'Timestamp(Millisecond, None)') as millis,
+  arrow_cast(column1, 'Timestamp(Second, None)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query PPPPT
+select * from t;
+----
+2018-11-13T17:11:10.011375885 2018-11-13T17:11:10.011375 2018-11-13T17:11:10.011 2018-11-13T17:11:10 Row 0
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10 Row 1
+NULL NULL NULL NULL Row 2
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10 Row 3
+
+
+# aggregate_timestamps_sum() -> Result<()> {

Review Comment:
   I guess the part with function signature is excessive here



##########
datafusion/core/tests/sqllogictests/test_files/aggregate.slt:
##########
@@ -1284,3 +1284,148 @@ NULL 2
 
 statement ok
 drop table the_nulls;
+
+# All supported timestamp types
+
+# "nanos" --> TimestampNanosecondArray
+# "micros" --> TimestampMicrosecondArray
+# "millis" --> TimestampMillisecondArray
+# "secs" --> TimestampSecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('2018-11-13T17:11:10.011375885995', 'Row 0'),
+ ('2011-12-13T11:13:10.12345', 'Row 1'),
+ (null, 'Row 2'),
+ ('2021-1-1T05:11:10.432', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Timestamp(Nanosecond, None)') as nanos,
+  arrow_cast(column1, 'Timestamp(Microsecond, None)') as micros,
+  arrow_cast(column1, 'Timestamp(Millisecond, None)') as millis,
+  arrow_cast(column1, 'Timestamp(Second, None)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query PPPPT
+select * from t;
+----
+2018-11-13T17:11:10.011375885 2018-11-13T17:11:10.011375 2018-11-13T17:11:10.011 2018-11-13T17:11:10 Row 0
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10 Row 1
+NULL NULL NULL NULL Row 2
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10 Row 3
+
+
+# aggregate_timestamps_sum() -> Result<()> {
+statement error Error during planning: The function Sum does not support inputs of type Timestamp\(Nanosecond, None\)
+SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t;
+
+query IIII
+SELECT count(nanos), count(micros), count(millis), count(secs) FROM t;
+----
+3 3 3 3
+
+
+# aggregate_timestamps_min
+query PPPP
+SELECT min(nanos), min(micros), min(millis), min(secs) FROM t;
+----
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10
+
+# aggregate_timestamps_max
+query PPPP
+SELECT max(nanos), max(micros), max(millis), max(secs) FROM t;
+----
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10
+
+
+
+# aggregate_timestamps_avg
+statement error Error during planning: The function Avg does not support inputs of type Timestamp\(Nanosecond, None\).
+SELECT avg(nanos), avg(micros), avg(millis), avg(secs) FROM t
+
+
+statement ok
+drop table t_source;
+
+statement ok
+drop table t;
+
+# All supported time types
+
+# Columns are named:
+# "nanos" --> Time64NanosecondArray
+# "micros" --> Time64MicrosecondArray
+# "millis" --> Time32MillisecondArray
+# "secs" --> Time32SecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('18:06:30.243620451', 'Row 0'),
+ ('20:08:28.161121654', 'Row 1'),
+ ('19:11:04.156423842', 'Row 2'),
+ ('21:06:28.247821084', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Time64(Nanosecond)') as nanos,
+  arrow_cast(column1, 'Time64(Microsecond)') as micros,
+  arrow_cast(column1, 'Time32(Millisecond)') as millis,
+  arrow_cast(column1, 'Time32(Second)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query DDDDT
+select * from t;
+----
+18:06:30.243620451 18:06:30.243620 18:06:30.243 18:06:30 Row 0
+20:08:28.161121654 20:08:28.161121 20:08:28.161 20:08:28 Row 1
+19:11:04.156423842 19:11:04.156423 19:11:04.156 19:11:04 Row 2
+21:06:28.247821084 21:06:28.247821 21:06:28.247 21:06:28 Row 3
+
+# aggregate_times_sum
+statement error DataFusion error: Error during planning: The function Sum does not support inputs of type Time64\(Nanosecond\).
+SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t
+
+# aggregate_times_count() -> Result<()>

Review Comment:
   Same here regarding function signature.



##########
datafusion/core/tests/sqllogictests/test_files/aggregate.slt:
##########
@@ -1284,3 +1284,148 @@ NULL 2
 
 statement ok
 drop table the_nulls;
+
+# All supported timestamp types
+
+# "nanos" --> TimestampNanosecondArray
+# "micros" --> TimestampMicrosecondArray
+# "millis" --> TimestampMillisecondArray
+# "secs" --> TimestampSecondArray
+# "names" --> StringArray
+
+statement ok
+create table t_source
+as values
+ ('2018-11-13T17:11:10.011375885995', 'Row 0'),
+ ('2011-12-13T11:13:10.12345', 'Row 1'),
+ (null, 'Row 2'),
+ ('2021-1-1T05:11:10.432', 'Row 3');
+
+
+statement ok
+create table t as
+select
+  arrow_cast(column1, 'Timestamp(Nanosecond, None)') as nanos,
+  arrow_cast(column1, 'Timestamp(Microsecond, None)') as micros,
+  arrow_cast(column1, 'Timestamp(Millisecond, None)') as millis,
+  arrow_cast(column1, 'Timestamp(Second, None)') as secs,
+  column2 as names
+from t_source;
+
+# Demonstate the contents
+query PPPPT
+select * from t;
+----
+2018-11-13T17:11:10.011375885 2018-11-13T17:11:10.011375 2018-11-13T17:11:10.011 2018-11-13T17:11:10 Row 0
+2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123450 2011-12-13T11:13:10.123 2011-12-13T11:13:10 Row 1
+NULL NULL NULL NULL Row 2
+2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10.432 2021-01-01T05:11:10 Row 3
+
+
+# aggregate_timestamps_sum() -> Result<()> {
+statement error Error during planning: The function Sum does not support inputs of type Timestamp\(Nanosecond, None\)
+SELECT sum(nanos), sum(micros), sum(millis), sum(secs) FROM t;
+
+query IIII

Review Comment:
   Maybe it's wort adding test name for this case



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org