You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2024/05/16 23:35:48 UTC

(spark) branch master updated: [SPARK-48031][SQL][FOLLOW-UP] Use ANSI-enabled cast in view lookup test

This is an automated email from the ASF dual-hosted git repository.

gurwls223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new e9d4152a319a [SPARK-48031][SQL][FOLLOW-UP] Use ANSI-enabled cast in view lookup test
e9d4152a319a is described below

commit e9d4152a319af4ad138ad1a6eb87bdf0b051ec9e
Author: Hyukjin Kwon <gu...@apache.org>
AuthorDate: Fri May 17 08:35:37 2024 +0900

    [SPARK-48031][SQL][FOLLOW-UP] Use ANSI-enabled cast in view lookup test
    
    ### What changes were proposed in this pull request?
    
    This PR is a followup of https://github.com/apache/spark/pull/46267 that uses ANSI-enabled cast in the tests. It intentionally uses ANSI-enabled cast in `castColToType` when you look up a view.
    
    ### Why are the changes needed?
    
    In order to fix the scheduled CI build without ANSI:
    
    - https://github.com/apache/spark/actions/runs/9072308206/job/24960016975
    - https://github.com/apache/spark/actions/runs/9072308206/job/24960019187
    
    ```
    [info] - look up view relation *** FAILED *** (72 milliseconds)
    [info]   == FAIL: Plans do not match ===
    [info]    'SubqueryAlias spark_catalog.db3.view1                                                                                                                                                                                                                                                                                                                                                                          'SubqueryAlias spark_catalog.db3.view1
    [info]    +- View (`spark_catalog`.`db3`.`view1`, ['col1, 'col2, 'a, 'b])                                                                                                                                                                                                                                                                                                                                                 +- View (`spark_catalog`.`db3`.`view1`, ['col1, 'col2, 'a, 'b])
    [info]       +- 'Project [cast(getviewcolumnbynameandordinal(`spark_catalog`.`db3`.`view1`, col1, 0, 1) as int) AS col1#0, cast(getviewcolumnbynameandordinal(`spark_catalog`.`db3`.`view1`, col2, 0, 1) as string) AS col2#0, cast(getviewcolumnbynameandordinal(`spark_catalog`.`db3`.`view1`, a, 0, 1) as int) AS a#0, cast(getviewcolumnbynameandordinal(`spark_catalog`.`db3`.`view1`, b, 0, 1) as string) AS b#0]      +- 'Project [cast(getviewcolumnbynameandordinal(`spark_catalog`.`db3`.`view1 [...]
    [info]          +- 'Project [*]                                                                                                                                                                                                                                                                                                                                                                                                 +- 'Project [*]
    [info]             +- 'UnresolvedRelation [tbl1], [], false
    ```
    
    ```
    [info] - look up view created before Spark 3.0 *** FAILED *** (452 milliseconds)
    [info]   == FAIL: Plans do not match ===
    [info]    'SubqueryAlias spark_catalog.db3.view2                                                                                                                                                                                                                                                                                                          'SubqueryAlias spark_catalog.db3.view2
    [info]    +- View (`db3`.`view2`, ['col1, 'col2, 'a, 'b])                                                                                                                                                                                                                                                                                                 +- View (`db3`.`view2`, ['col1, 'col2, 'a, 'b])
    [info]       +- 'Project [cast(getviewcolumnbynameandordinal(`db3`.`view2`, col1, 0, 1) as int) AS col1#0, cast(getviewcolumnbynameandordinal(`db3`.`view2`, col2, 0, 1) as string) AS col2#0, cast(getviewcolumnbynameandordinal(`db3`.`view2`, a, 0, 1) as int) AS a#0, cast(getviewcolumnbynameandordinal(`db3`.`view2`, b, 0, 1) as string) AS b#0]      +- 'Project [cast(getviewcolumnbynameandordinal(`db3`.`view2`, col1, 0, 1) as int) AS col1#0, cast(getviewcolumnbynameandordinal(`db3`.`view [...]
    [info]          +- 'Project [*]                                                                                                                                                                                                                                                                                                                                 +- 'Project [*]
    [info]             +- 'UnresolvedRelation [tbl1], [], false                                                                                                                                                                                                                                                                                                        +- 'UnresolvedRelation [tbl1], [], false (PlanTest.scala:179)
    
    ```
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, the main change has not been released yet.
    
    ### How was this patch tested?
    
    Manually ran the tests after ANSI disabled.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #46614 from HyukjinKwon/SPARK-48031-followup.
    
    Authored-by: Hyukjin Kwon <gu...@apache.org>
    Signed-off-by: Hyukjin Kwon <gu...@apache.org>
---
 .../org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
index 1d6d07c7a9ce..5fa10db6457f 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
@@ -744,7 +744,8 @@ abstract class SessionCatalogSuite extends AnalysisTest with Eventually {
     val projectList = metadata.schema.map { field =>
       Cast(
         GetViewColumnByNameAndOrdinal(metadata.identifier.toString, field.name, 0, 1, None),
-        field.dataType).as(field.name)
+        field.dataType,
+        ansiEnabled = true).as(field.name)
     }
     Project(projectList, CatalystSqlParser.parsePlan(metadata.viewText.get))
   }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org