-
Notifications
You must be signed in to change notification settings - Fork 286
Add WEEK() function mode parameter support and configurable CTE max recursion depth #23268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
You are nearing your monthly Qodo Merge usage quota. For more information, please visit here. PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
Merge Queue Status✅ The pull request has been merged at 57050c5 This pull request spent 7 seconds in the queue, with no time running CI. Required conditions to merge
|
User description
What type of PR is this?
Which issue(s) this PR fixes:
issue #23265
What this PR does / why we need it:
This PR adds two enhancements:
function specification.
hierarchical queries when needed.
PR Type
Enhancement, Bug fix
Description
Add optional mode parameter (0-7) to WEEK() function for date/datetime types
Make CTE max recursion depth configurable via SET cte_max_recursion_depth variable
Add comprehensive test coverage for WEEK() mode parameter and CTE recursion depth
Should we remain consistent with MySQL?
MySQL:
MO:
Normal Cases (MySQL and MO results are identical ✅)
Invalid Cases (MySQL and MO behavior differs⚠️ )
Prerequisites
Normal Cases (MySQL and MO results are identical ✅)
Invalid Cases (MySQL and MO behavior differs⚠️ )
Diagram Walkthrough
File Walkthrough
func_unary.go
Add mode parameter support to WEEK functionspkg/sql/plan/function/func_unary.go
DateToWeek()to support optional mode parameter withvalidation
DatetimeToWeek()to support optional mode parameter withvalidation
WeekOfYear2()calls withWeek(mode)method callsextraction and null handling
list_builtIn.go
Register WEEK function overloads with mode parameterpkg/sql/plan/function/list_builtIn.go
WEEK(date, int64)returning uint8WEEK(datetime, int64)returning uint8overloads
mergecte.go
Make CTE recursion limit configurable via variablepkg/sql/colexec/mergecte/mergecte.go
moDefaultRecursionMaxwith dynamic variableresolution
proc.GetResolveVariableFunc()call to fetchcte_max_recursion_depthvariablefunc_date.sql
Add WEEK function mode parameter test casestest/distributed/cases/function/func_date.sql
func_date.result
Update WEEK function test results with mode parametertest/distributed/cases/function/func_date.result
recursive_cte.sql
Add CTE recursion depth configuration test casestest/distributed/cases/recursive_cte/recursive_cte.sql
cte_max_recursion_depthvariablerecursive_cte.result
Update recursive CTE test results with configurable depthtest/distributed/cases/recursive_cte/recursive_cte.result
depth
case
it