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 2022/04/19 10:34:11 UTC

[GitHub] [arrow-datafusion] yjshen opened a new pull request, #2272: Fix outer join output with all-null indices

yjshen opened a new pull request, #2272:
URL: https://github.com/apache/arrow-datafusion/pull/2272

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #2268.
   
    # Rationale for this change
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   Fix `take` all-null indices from empty batch during join output.
   
   # What changes are included in this PR?
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   FIx along with a test.
   
   # Are there any user-facing changes?
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   No.
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->
   No.
   


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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #2272: Fix outer join output with all-null indices on empty batch

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #2272:
URL: https://github.com/apache/arrow-datafusion/pull/2272#discussion_r853024746


##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -948,3 +948,60 @@ async fn join_timestamp() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn left_join_should_not_panic_with_empty_side() -> Result<()> {
+    let ctx = SessionContext::new();
+
+    let t1_schema = Schema::new(vec![
+        Field::new("t1_id", DataType::Int64, true),
+        Field::new("t1_value", DataType::Utf8, false),
+    ]);
+    let t1_data = RecordBatch::try_new(
+        Arc::new(t1_schema),
+        vec![
+            Arc::new(Int64Array::from_slice(&[5247, 3821, 6321, 8821, 7748])),
+            Arc::new(StringArray::from_slice(&["a", "b", "c", "d", "e"])),
+        ],
+    )?;
+    let t1_table = MemTable::try_new(t1_data.schema(), vec![vec![t1_data]])?;
+    ctx.register_table("t1", Arc::new(t1_table))?;
+
+    let t2_schema = Schema::new(vec![
+        Field::new("t2_id", DataType::Int64, true),
+        Field::new("t2_value", DataType::Boolean, true),
+    ]);
+    let t2_data = RecordBatch::try_new(
+        Arc::new(t2_schema),
+        vec![
+            Arc::new(Int64Array::from_slice(&[358, 2820, 3804, 7748])),
+            Arc::new(BooleanArray::from(vec![
+                Some(true),
+                Some(false),
+                None,
+                None,
+            ])),
+        ],
+    )?;
+    let t2_table = MemTable::try_new(t2_data.schema(), vec![vec![t2_data]])?;
+    ctx.register_table("t2", Arc::new(t2_table))?;
+
+    let expected = vec![
+        "+-------+----------+-------+----------+",
+        "| t1_id | t1_value | t2_id | t2_value |",
+        "+-------+----------+-------+----------+",
+        "| 5247  | a        |       |          |",
+        "| 3821  | b        |       |          |",
+        "| 6321  | c        |       |          |",
+        "| 8821  | d        |       |          |",
+        "| 7748  | e        | 7748  |          |",
+        "+-------+----------+-------+----------+",
+    ];
+
+    let results =
+        execute_to_batches(&ctx, "SELECT * FROM t1 LEFT JOIN t2 ON t1_id = t2_id").await;

Review Comment:
   Maybe we can also check right join (as it is covered above too) via:
   
   
   ```
    let results =
           execute_to_batches(&ctx, "SELECT * FROM t2 RIGHT JOIN t1 ON t1_id = t2_id").await;
   ```



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


[GitHub] [arrow-datafusion] yjshen merged pull request #2272: Fix outer join output with all-null indices on empty batch

Posted by GitBox <gi...@apache.org>.
yjshen merged PR #2272:
URL: https://github.com/apache/arrow-datafusion/pull/2272


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


[GitHub] [arrow-datafusion] yjshen commented on a diff in pull request #2272: Fix outer join output with all-null indices on empty batch

Posted by GitBox <gi...@apache.org>.
yjshen commented on code in PR #2272:
URL: https://github.com/apache/arrow-datafusion/pull/2272#discussion_r853225370


##########
datafusion/core/tests/sql/joins.rs:
##########
@@ -948,3 +948,60 @@ async fn join_timestamp() -> Result<()> {
 
     Ok(())
 }
+
+#[tokio::test]
+async fn left_join_should_not_panic_with_empty_side() -> Result<()> {
+    let ctx = SessionContext::new();
+
+    let t1_schema = Schema::new(vec![
+        Field::new("t1_id", DataType::Int64, true),
+        Field::new("t1_value", DataType::Utf8, false),
+    ]);
+    let t1_data = RecordBatch::try_new(
+        Arc::new(t1_schema),
+        vec![
+            Arc::new(Int64Array::from_slice(&[5247, 3821, 6321, 8821, 7748])),
+            Arc::new(StringArray::from_slice(&["a", "b", "c", "d", "e"])),
+        ],
+    )?;
+    let t1_table = MemTable::try_new(t1_data.schema(), vec![vec![t1_data]])?;
+    ctx.register_table("t1", Arc::new(t1_table))?;
+
+    let t2_schema = Schema::new(vec![
+        Field::new("t2_id", DataType::Int64, true),
+        Field::new("t2_value", DataType::Boolean, true),
+    ]);
+    let t2_data = RecordBatch::try_new(
+        Arc::new(t2_schema),
+        vec![
+            Arc::new(Int64Array::from_slice(&[358, 2820, 3804, 7748])),
+            Arc::new(BooleanArray::from(vec![
+                Some(true),
+                Some(false),
+                None,
+                None,
+            ])),
+        ],
+    )?;
+    let t2_table = MemTable::try_new(t2_data.schema(), vec![vec![t2_data]])?;
+    ctx.register_table("t2", Arc::new(t2_table))?;
+
+    let expected = vec![
+        "+-------+----------+-------+----------+",
+        "| t1_id | t1_value | t2_id | t2_value |",
+        "+-------+----------+-------+----------+",
+        "| 5247  | a        |       |          |",
+        "| 3821  | b        |       |          |",
+        "| 6321  | c        |       |          |",
+        "| 8821  | d        |       |          |",
+        "| 7748  | e        | 7748  |          |",
+        "+-------+----------+-------+----------+",
+    ];
+
+    let results =
+        execute_to_batches(&ctx, "SELECT * FROM t1 LEFT JOIN t2 ON t1_id = t2_id").await;

Review Comment:
   Added.



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