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

[GitHub] [arrow-datafusion] jackwener opened a new pull request, #6614: fix: remove type coercion of case expression in Expr::Schema

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

   # 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 #5821.
   
   # 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.  
   -->
   
   # 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.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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] jackwener commented on pull request #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614#issuecomment-1584828814

   cc @alamb @liukun4515 @mslapek 


-- 
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 #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614#discussion_r1224582709


##########
datafusion/core/tests/sql/mod.rs:
##########
@@ -971,13 +971,8 @@ async fn plan_and_collect(ctx: &SessionContext, sql: &str) -> Result<Vec<RecordB
 async fn execute_to_batches(ctx: &SessionContext, sql: &str) -> Vec<RecordBatch> {
     let df = ctx.sql(sql).await.unwrap();
 
-    // We are not really interested in the direct output of optimized_logical_plan
-    // since the physical plan construction already optimizes the given logical plan
-    // and we want to avoid double-optimization as a consequence. So we just construct
-    // it here to make sure that it doesn't fail at this step and get the optimized
-    // schema (to assert later that the logical and optimized schemas are the same).
-    let optimized = df.clone().into_optimized_plan().unwrap();
-    assert_eq!(df.logical_plan().schema(), optimized.schema());

Review Comment:
   I agree this check predated the existence of the analyzer



-- 
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] jackwener commented on a diff in pull request #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614#discussion_r1224480438


##########
datafusion/core/tests/sql/mod.rs:
##########
@@ -971,13 +971,8 @@ async fn plan_and_collect(ctx: &SessionContext, sql: &str) -> Result<Vec<RecordB
 async fn execute_to_batches(ctx: &SessionContext, sql: &str) -> Vec<RecordBatch> {
     let df = ctx.sql(sql).await.unwrap();
 
-    // We are not really interested in the direct output of optimized_logical_plan
-    // since the physical plan construction already optimizes the given logical plan
-    // and we want to avoid double-optimization as a consequence. So we just construct
-    // it here to make sure that it doesn't fail at this step and get the optimized
-    // schema (to assert later that the logical and optimized schemas are the same).
-    let optimized = df.clone().into_optimized_plan().unwrap();
-    assert_eq!(df.logical_plan().schema(), optimized.schema());

Review Comment:
   we shouldn't check schema here.
   Because analyzer will change schema



-- 
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] jackwener commented on a diff in pull request #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614#discussion_r1224480438


##########
datafusion/core/tests/sql/mod.rs:
##########
@@ -971,13 +971,8 @@ async fn plan_and_collect(ctx: &SessionContext, sql: &str) -> Result<Vec<RecordB
 async fn execute_to_batches(ctx: &SessionContext, sql: &str) -> Vec<RecordBatch> {
     let df = ctx.sql(sql).await.unwrap();
 
-    // We are not really interested in the direct output of optimized_logical_plan
-    // since the physical plan construction already optimizes the given logical plan
-    // and we want to avoid double-optimization as a consequence. So we just construct
-    // it here to make sure that it doesn't fail at this step and get the optimized
-    // schema (to assert later that the logical and optimized schemas are the same).
-    let optimized = df.clone().into_optimized_plan().unwrap();
-    assert_eq!(df.logical_plan().schema(), optimized.schema());

Review Comment:
   we shouldn't check schema here.
   Because analyzer will change schema
   
   optimizer already contain `schema` checker, so we don't need `assert_eq`



-- 
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] jackwener commented on a diff in pull request #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614#discussion_r1224350123


##########
datafusion/core/tests/sqllogictests/test_files/scalar.slt:
##########
@@ -646,27 +646,27 @@ SELECT CASE WHEN NULL THEN 'foo' ELSE 'bar' END
 bar
 
 # case_expr_with_null()
-query I
+query ?

Review Comment:
   It's strange. I can't understand it.
   
   I exec sql to confirm `type coercion` is right
   
   ```sql
    select arrow_typeof(case when b is null then null else b end) from (select a,b from (values (1,null),(2,3)) as t (a,b)) a;
   
   +------------------------------------------------------------+
   | arrow_typeof(CASE WHEN a.b IS NULL THEN NULL ELSE a.b END) |
   +------------------------------------------------------------+
   | Int64                                                      |
   | Int64                                                      |
   +------------------------------------------------------------+
   ```



-- 
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 merged pull request #6614: fix: remove type coercion of case expression in Expr::Schema

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb merged PR #6614:
URL: https://github.com/apache/arrow-datafusion/pull/6614


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