You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "guixiaowen (via GitHub)" <gi...@apache.org> on 2024/04/26 09:57:54 UTC

[PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #46243:
URL: https://github.com/apache/spark/pull/46243#issuecomment-2299980951

   We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
   If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

Posted by "guixiaowen (via GitHub)" <gi...@apache.org>.
guixiaowen commented on PR #46243:
URL: https://github.com/apache/spark/pull/46243#issuecomment-2099929746

   @yaooqinn hi, Can you help me review this PR?


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #46243: [SPARK-48006][SQL]add SortOrder for window function which has no orde…
URL: https://github.com/apache/spark/pull/46243


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

Posted by "guixiaowen (via GitHub)" <gi...@apache.org>.
guixiaowen commented on PR #46243:
URL: https://github.com/apache/spark/pull/46243#issuecomment-2094808977

   @dongjoon-hyun  hi, Can you help me review this PR?


-- 
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-unsubscribe@spark.apache.org

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


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


Re: [PR] [SPARK-48006][SQL]add SortOrder for window function which has no orde… [spark]

Posted by "guixiaowen (via GitHub)" <gi...@apache.org>.
guixiaowen commented on PR #46243:
URL: https://github.com/apache/spark/pull/46243#issuecomment-2103950423

   @dongjoon-hyun  hi, Can you help me review this PR?


-- 
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-unsubscribe@spark.apache.org

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


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