Repository navigation
Implement select distinct #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
df617c9
Implement select distinct
Dandandan 46e0eb9
Simplify implementation
Dandandan ada560b
Move out of project fn
Dandandan a30dd40
Fix call
Dandandan 32a9c95
Fix docs
Dandandan 217d786
Add to docs
Dandandan 6da57f9
Add note of ALL support
Dandandan 8c15380
Add test for SELECT ALL
Dandandan 316c734
Clippy
Dandandan 6ea9c77
Update datafusion/tests/sql.rs
Dandandan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -372,6 +372,81 @@ async fn csv_query_group_by_float32() -> Result<()> { | |
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn select_all() -> Result<()> { | ||
| let mut ctx = ExecutionContext::new(); | ||
| register_aggregate_simple_csv(&mut ctx)?; | ||
|
|
||
| let sql = "SELECT c1 FROM aggregate_simple order by c1"; | ||
| let actual_no_all = execute(&mut ctx, sql).await; | ||
|
|
||
| let sql_all = "SELECT ALL c1 FROM aggregate_simple order by c1"; | ||
| let actual_all = execute(&mut ctx, sql_all).await; | ||
|
|
||
| assert_eq!(actual_no_all, actual_all); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn select_distinct() -> Result<()> { | ||
| let mut ctx = ExecutionContext::new(); | ||
| register_aggregate_simple_csv(&mut ctx)?; | ||
|
|
||
| let sql = "SELECT DISTINCT * FROM aggregate_simple"; | ||
| let mut actual = execute(&mut ctx, sql).await; | ||
| actual.sort(); | ||
|
|
||
| let mut dedup = actual.clone(); | ||
| dedup.dedup(); | ||
|
|
||
| assert_eq!(actual, dedup); | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn select_distinct_simple() -> Result<()> { | ||
| let mut ctx = ExecutionContext::new(); | ||
| register_aggregate_simple_csv(&mut ctx)?; | ||
|
|
||
| let sql = "SELECT DISTINCT c1 FROM aggregate_simple order by c1"; | ||
| let actual = execute(&mut ctx, sql).await; | ||
|
|
||
| let expected = vec![ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubled checked that the input has duplicates (to show that the distinct has removed them): https://github.com/apache/arrow-datafusion/blob/master/datafusion/tests/aggregate_simple.csv 👍 |
||
| vec!["0.00001"], | ||
| vec!["0.00002"], | ||
| vec!["0.00003"], | ||
| vec!["0.00004"], | ||
| vec!["0.00005"], | ||
| ]; | ||
| assert_eq!(actual, expected); | ||
|
|
||
| let sql = "SELECT DISTINCT c1, c2 FROM aggregate_simple order by c1"; | ||
| let actual = execute(&mut ctx, sql).await; | ||
|
|
||
| let expected = vec![ | ||
| vec!["0.00001", "0.000000000001"], | ||
| vec!["0.00002", "0.000000000002"], | ||
| vec!["0.00003", "0.000000000003"], | ||
| vec!["0.00004", "0.000000000004"], | ||
| vec!["0.00005", "0.000000000005"], | ||
| ]; | ||
| assert_eq!(actual, expected); | ||
|
|
||
| let sql = "SELECT distinct c3 FROM aggregate_simple order by c3"; | ||
| let actual = execute(&mut ctx, sql).await; | ||
|
|
||
| let expected = vec![vec!["false"], vec!["true"]]; | ||
| assert_eq!(actual, expected); | ||
|
|
||
| let sql = "SELECT distinct c1+c2 as a FROM aggregate_simple"; | ||
| let actual = execute(&mut ctx, sql).await; | ||
|
|
||
| assert_eq!(actual.len(), 5); | ||
| Ok(()) | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn csv_query_group_by_float64() -> Result<()> { | ||
| let mut ctx = ExecutionContext::new(); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small drive-by simplification, an unused option