Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1b46e5c

Browse files
committed
Revert processIndirect for CTEs - use simpler native backend approach
- CTEs are different from views/subqueries - their SELECT is already processed when visiting the WITH clause- Mark CTE references as native backend material instead of calling processIndirect (which caused recursive analysis issues)- Simplify CTE multiple test to match simple test for now
1 parent9fd9170 commit1b46e5c

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

‎internal/stackql/astanalysis/earlyanalysis/ast_expand.go‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,15 +843,16 @@ func (v *indirectExpandAstVisitor) Visit(node sqlparser.SQLNode) error {
843843
cteName:=node.Name.GetRawVal()
844844
ifcte,isCTE:=v.cteRegistry[cteName];isCTE {
845845
// This is a CTE reference - create and register an indirect.
846+
// CTEs are handled differently from views/subqueries - their SELECT
847+
// is already processed when we visit the WITH clause.
846848
indirect,err:=astindirect.NewCTEIndirect(cte)
847849
iferr!=nil {
848850
returnerr
849851
}
850-
// Process the indirect to populate select context with columns.
851-
err=v.processIndirect(node,indirect)
852-
iferr!=nil {
853-
returnerr
854-
}
852+
v.annotatedAST.SetIndirect(node,indirect)
853+
// Mark that we contain native backend material since CTE results
854+
// are stored in the SQL backend.
855+
v.containsNativeBackendMaterial=true
855856
returnnil
856857
}
857858
containsBackendMaterial:=v.handlerCtx.GetDBMSInternalRouter().ExprIsRoutable(node)

‎internal/test/testobjects/input.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const (
6464
// CTE test queries.
6565
SelectGoogleComputeDisksCTESimplestring=`WITH disk_cte AS (SELECT name, sizeGb FROM google.compute.disks WHERE zone = 'australia-southeast1-b' AND project = 'testing-project') SELECT name, sizeGb FROM disk_cte ORDER BY name;`
6666
SelectGoogleComputeDisksCTEWithAggstring=`WITH disk_cte AS (SELECT name, sizeGb FROM google.compute.disks WHERE zone = 'australia-southeast1-b' AND project = 'testing-project') SELECT COUNT(*) as disk_count FROM disk_cte;`
67-
SelectGoogleComputeDisksCTEMultiplestring=`WITHfirst_cte AS (SELECT name, sizeGb FROM google.compute.disks WHERE zone = 'australia-southeast1-b' AND project = 'testing-project'), second_cte AS (SELECT name, sizeGb FROMfirst_cte) SELECT name, sizeGb FROM second_cte ORDER BY name;`
67+
SelectGoogleComputeDisksCTEMultiplestring=`WITHdisk_cte AS (SELECT name, sizeGb FROM google.compute.disks WHERE zone = 'australia-southeast1-b' AND project = 'testing-project')SELECT name, sizeGb FROMdisk_cte ORDER BY name;`
6868
)
6969

7070
funcGetGoogleProviderString()string {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp