You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "erenavsarogullari (via GitHub)" <gi...@apache.org> on 2026/02/18 04:13:51 UTC
[PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
erenavsarogullari opened a new pull request, #20420:
URL: https://github.com/apache/datafusion/pull/20420
## Which issue does this PR close?
- Closes #20419.
## Rationale for this change
This PR adds new positive and negative test cases for `datafusion-spark` array functions: `array_repeat `, `shuffle`, `slice` for the following use-cases:
```
- nested function execution,
- invalid parameter settings to verify validation,
- different datatypes such as timestamp,
- casting before function execution
```
## What changes are included in this PR?
Being added new positive and negative test cases to `datafusion-spark` array functions: `array_repeat `, `shuffle`, `slice`.
## Are these changes tested?
Yes, adding new positive and negative test cases.
## Are there any user-facing changes?
Yes, updating error message by adding `single quote` for specific keywords to highlight.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead merged PR #20420:
URL: https://github.com/apache/datafusion/pull/20420
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2834311221
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,6 +87,26 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
Review Comment:
In general, shuffle function is `non-deterministic`. However, it can also return `deterministic` result by passing `seed` for specially this kind of cases.
For reference:
- Spark Shuffle function accepts `optional randomSeed` argument to :
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L1264
- On the other hand, current DF-Spark Shuffle func implementation support following both cases by accepting both arguments for the alignment with Spark:
```
shuffle(array)
shuffle(array, seed)
```
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#issuecomment-3936492120
Thanks everyone
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2834348426
##########
docs/source/contributor-guide/testing.md:
##########
@@ -70,7 +70,9 @@ DataFusion's SQL implementation is tested using [sqllogictest](https://github.co
cargo test --profile=ci --test sqllogictests
# Run a specific test file
cargo test --profile=ci --test sqllogictests -- aggregate.slt
-# Run and update expected outputs
+# Run a specific test file and update expected outputs
+cargo test --profile=ci --test sqllogictests -- aggregate.slt --complete
Review Comment:
I have covered this doc update here because of a minor change
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2834311221
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,6 +87,26 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
Review Comment:
In general, `shuffle` function is `non-deterministic`. However, it can also return `deterministic` result by passing `seed` for specially this kind of cases (e.g: test verification).
For reference:
- Spark `shuffle` function accepts `optional randomSeed` argument to :
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L1264
- On the other hand, current DF-Spark `shuffle` func implementation support following both cases by accepting both arguments for the alignment with Spark:
```
shuffle(array)
shuffle(array, seed)
```
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2825539887
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,9 +87,36 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
-# Clean up
-statement ok
-DROP TABLE test_shuffle_list_types;
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
+----
+[2001-09-28T01:00:00, 2001-06-28T01:00:00, 2001-07-28T01:00:00, 2001-08-28T01:00:00, 2001-05-28T01:00:00]
-statement ok
-DROP TABLE test_shuffle_fixed_size;
+query ?
+SELECT shuffle(shuffle([1, 20, NULL, 3, 100, NULL, 98, 99], 1), 1);
+----
+[1, 99, NULL, 98, 100, NULL, 3, 20]
+
+query ?
+SELECT shuffle([' ', NULL, 'abc'], 1);
+----
+[ , NULL, abc]
+
+query ?
+SELECT shuffle([1, 2, 3, 4], CAST('2' AS INT));
+----
+[1, 4, 2, 3]
+
+
+query error
+SELECT shuffle([2, 1, 'abc'], 1);
+----
+DataFusion error: Optimizer rule 'simplify_expressions' failed
+caused by
+Arrow error: Cast error: Cannot cast string 'abc' to value of Int64 type
+
+
+query error
+SELECT shuffle([2, 1], NULL);
+----
+DataFusion error: Execution error: shuffle seed must be Int64 type, got 'Int64'
Review Comment:
Reverted negative cases for now.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2834311221
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,6 +87,26 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
Review Comment:
In general, shuffle function is `non-deterministic`. However, it can also return `deterministic` result by passing `seed` for specially this kind of cases (e.g: test verification).
For reference:
- Spark Shuffle function accepts `optional randomSeed` argument to :
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/collectionOperations.scala#L1264
- On the other hand, current DF-Spark Shuffle func implementation support following both cases by accepting both arguments for the alignment with Spark:
```
shuffle(array)
shuffle(array, seed)
```
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2825396961
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,9 +87,36 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
-# Clean up
-statement ok
-DROP TABLE test_shuffle_list_types;
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
+----
+[2001-09-28T01:00:00, 2001-06-28T01:00:00, 2001-07-28T01:00:00, 2001-08-28T01:00:00, 2001-05-28T01:00:00]
-statement ok
-DROP TABLE test_shuffle_fixed_size;
Review Comment:
Might be nice to keep these drops
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,9 +87,36 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
-# Clean up
-statement ok
-DROP TABLE test_shuffle_list_types;
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
+----
+[2001-09-28T01:00:00, 2001-06-28T01:00:00, 2001-07-28T01:00:00, 2001-08-28T01:00:00, 2001-05-28T01:00:00]
-statement ok
-DROP TABLE test_shuffle_fixed_size;
+query ?
+SELECT shuffle(shuffle([1, 20, NULL, 3, 100, NULL, 98, 99], 1), 1);
+----
+[1, 99, NULL, 98, 100, NULL, 3, 20]
+
+query ?
+SELECT shuffle([' ', NULL, 'abc'], 1);
+----
+[ , NULL, abc]
+
+query ?
+SELECT shuffle([1, 2, 3, 4], CAST('2' AS INT));
+----
+[1, 4, 2, 3]
+
+
+query error
+SELECT shuffle([2, 1, 'abc'], 1);
+----
+DataFusion error: Optimizer rule 'simplify_expressions' failed
+caused by
+Arrow error: Cast error: Cannot cast string 'abc' to value of Int64 type
+
+
+query error
+SELECT shuffle([2, 1], NULL);
+----
+DataFusion error: Execution error: shuffle seed must be Int64 type, got 'Int64'
Review Comment:
This seems a bit odd?
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2828827401
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,6 +87,26 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
Review Comment:
not related to the PR, but how it comes `shuffle` which is non deterministic https://spark.apache.org/docs/latest/api/sql/#shuffle has stable output 🤔
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2828792775
##########
docs/source/contributor-guide/testing.md:
##########
@@ -70,7 +70,9 @@ DataFusion's SQL implementation is tested using [sqllogictest](https://github.co
cargo test --profile=ci --test sqllogictests
# Run a specific test file
cargo test --profile=ci --test sqllogictests -- aggregate.slt
-# Run and update expected outputs
+# Run a specific test file and update expected outputs
+cargo test --profile=ci --test sqllogictests -- aggregate.slt --complete
Review Comment:
this looks unrelated to the PR
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "Jefffrey (via GitHub)" <gi...@apache.org>.
Jefffrey commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2833009505
##########
docs/source/contributor-guide/testing.md:
##########
@@ -70,7 +70,9 @@ DataFusion's SQL implementation is tested using [sqllogictest](https://github.co
cargo test --profile=ci --test sqllogictests
# Run a specific test file
cargo test --profile=ci --test sqllogictests -- aggregate.slt
-# Run and update expected outputs
+# Run a specific test file and update expected outputs
+cargo test --profile=ci --test sqllogictests -- aggregate.slt --complete
Review Comment:
It seems a nice improvement regardless
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,6 +87,26 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
Review Comment:
We're providing a seed for deterministic output
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] test: Extend Spark Array functions: `array_repeat `, `shuffle` and `slice` test coverage [datafusion]
Posted by "erenavsarogullari (via GitHub)" <gi...@apache.org>.
erenavsarogullari commented on code in PR #20420:
URL: https://github.com/apache/datafusion/pull/20420#discussion_r2825538140
##########
datafusion/sqllogictest/test_files/spark/array/shuffle.slt:
##########
@@ -87,9 +87,36 @@ SELECT shuffle(column1, 1) FROM test_shuffle_fixed_size;
[9, NULL, 8]
NULL
-# Clean up
-statement ok
-DROP TABLE test_shuffle_list_types;
+query ?
+SELECT shuffle(['2001-09-28T01:00:00'::timestamp, '2001-08-28T01:00:00'::timestamp, '2001-07-28T01:00:00'::timestamp, '2001-06-28T01:00:00'::timestamp, '2001-05-28T01:00:00'::timestamp], 1);
+----
+[2001-09-28T01:00:00, 2001-06-28T01:00:00, 2001-07-28T01:00:00, 2001-08-28T01:00:00, 2001-05-28T01:00:00]
-statement ok
-DROP TABLE test_shuffle_fixed_size;
Review Comment:
Addressed
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org