guixiaowen opened a new pull request, #46243:
URL: https://github.com/apache/spark/pull/46243

   
   
   ### What changes were proposed in this pull request?
   I am doing Hive SQL to switch to Spark SQL.
   
    
   
   In Hive SQL
   
    
   
   hive> explain select *,row_number() over (partition by day) rn from 
testdb.zeropart_db;
   
   OK
   Explain
   
    
   
   In Spark SQL
   
   spark-sql> explain select *,row_number() over (partition by age ) rn  from 
testdb.zeropart_db;
   
   plan
   
   == Physical Plan ==
   
   org.apache.spark.sql.AnalysisException: Window function row_number() 
requires window to be ordered, please add ORDER BY clause. For example SELECT 
row_number()(value_expr) OVER (PARTITION BY window_partition ORDER BY 
window_ordering) from table
   
   Time taken: 0.172 seconds, Fetched 1 row(s)
   
    
   
   For better compatibility with migration. For better compatibility with 
migration, new parameters are added to ensure compatibility with the same 
behavior as Hive SQL
   
   
   ### Why are the changes needed?
   For better compatibility with migration. 
   
   
   ### Does this PR introduce _any_ user-facing change?
   before this pr:
   
   spark-sql> explain select *,row_number() over (partition by age ) rn  from 
testdb.zeropart_db;
   
   plan
   
   == Physical Plan ==
   
   org.apache.spark.sql.AnalysisException: Window function row_number() 
requires window to be ordered, please add ORDER BY clause. For example SELECT 
row_number()(value_expr) OVER (PARTITION BY window_partition ORDER BY 
window_ordering) from table
   
   Time taken: 0.172 seconds, Fetched 1 row(s)
   
   after this pr:
   
   spark-sql> explain select *,row_number() over (partition by age ) rn  from 
testdb.zeropart_db;
   plan
   == Physical Plan ==
   AdaptiveSparkPlan isFinalPlan=false
   +- Window [row_number() windowspecdefinition(age#37, age#37 ASC NULLS FIRST, 
specifiedwindowframe(RowFrame, unboundedpreceding$(), currentrow$())) AS 
rn#30], [age#37], [age#37 ASC NULLS FIRST]
      +- Sort [age#37 ASC NULLS FIRST, age#37 ASC NULLS FIRST], false, 0
         +- Exchange hashpartitioning(age#37, 1000), ENSURE_REQUIREMENTS, 
[id=#53]
            +- Scan hive testdb.zeropart_db [age#37, sex#38, name#39, day#40], 
HiveTableRelation [`bigdata_qa`.`zeropart_db`, 
org.apache.hadoop.hive.ql.io.orc.OrcSerde, Data Cols: [age#37, sex#38, 
name#39], Partition Cols: [day#40]]
   
   
   Time taken: 0.154 seconds, Fetched 1 row(s)
   
   
   
   
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some 
test cases that check the changes thoroughly including negative and positive 
cases if possible.
   If it was tested in a way different from regular unit tests, please clarify 
how you tested step by step, ideally copy and paste-able, so that other 
reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why 
it was difficult to add.
   If benchmark tests were added, please run the benchmarks in GitHub Actions 
for the consistent environment, and the instructions could accord to: 
https://spark.apache.org/developer-tools.html#github-workflow-benchmarks.
   -->
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   <!--
   If generative AI tooling has been used in the process of authoring this 
patch, please include the
   phrase: 'Generated-by: ' followed by the name of the tool and its version.
   If no, write 'No'.
   Please refer to the [ASF Generative Tooling 
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
   -->
   


-- 
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: reviews-unsubscr...@spark.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to