You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/05/04 22:13:59 UTC

[GitHub] [arrow-datafusion] alamb commented on a change in pull request #262: Implement select distinct

alamb commented on a change in pull request #262:
URL: https://github.com/apache/arrow-datafusion/pull/262#discussion_r626143799



##########
File path: datafusion/tests/sql.rs
##########
@@ -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_all() -> Result<()> {

Review comment:
       ```suggestion
   async fn select_distinct() -> Result<()> {
   ```

##########
File path: datafusion/tests/sql.rs
##########
@@ -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_all() -> 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![

Review comment:
       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
   
   👍 




-- 
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.

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