Skip to content

Commit e98c87a

Browse files
- PAtched unit testing garbage.
1 parent 2b140e5 commit e98c87a

File tree

10 files changed

+40
-15
lines changed

10 files changed

+40
-15
lines changed

internal/stackql/execution/mono_valent_execution.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,7 @@ func GetMonitorExecutor(
14781478
precursor primitive.IPrimitive,
14791479
initialCtx primitive.IPrimitiveCtx,
14801480
comments sqlparser.CommentDirectives,
1481+
isReturning bool,
14811482
) (primitive.IPrimitive, error) {
14821483
m := op
14831484
// tableName, err := mv.tableMeta.GetTableName()
@@ -1528,7 +1529,7 @@ func GetMonitorExecutor(
15281529
//nolint:nestif // acceptable for now
15291530
if endTimeOk && endTime != "" {
15301531
targetLink, targetLinkOK := body["targetLink"]
1531-
if targetLinkOK {
1532+
if targetLinkOK && isReturning {
15321533
authCtx, authErr := pc.GetAuthContext(prStr)
15331534
if authErr != nil {
15341535
return internaldto.NewExecutorOutput(nil, nil, nil, nil, authErr)
@@ -1568,6 +1569,7 @@ func GetMonitorExecutor(
15681569
}
15691570
return prepareResultSet(&asyncPrim, pc, target, operationDescriptor)
15701571
}
1572+
return prepareResultSet(&asyncPrim, pc, body, operationDescriptor)
15711573
}
15721574
url, ok := body["selfLink"]
15731575
if !ok {

internal/stackql/internal_data_transfer/builder_input/builder_input.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ type BuilderInput interface {
3131
GetOperationStore() (anysdk.OperationStore, bool)
3232
SetOperationStore(op anysdk.OperationStore)
3333
IsAwait() bool
34+
IsReturning() bool
35+
SetIsReturning(bool)
3436
GetVerb() string
3537
GetInputAlias() string
3638
IsUndo() bool
@@ -64,6 +66,7 @@ type builderInput struct {
6466
dependencyNode primitivegraph.PrimitiveNode
6567
commentDirectives sqlparser.CommentDirectives
6668
isAwait bool
69+
isReturning bool
6770
verb string
6871
inputAlias string
6972
isUndo bool
@@ -92,6 +95,14 @@ func NewBuilderInput(
9295
}
9396
}
9497

98+
func (bi *builderInput) IsReturning() bool {
99+
return bi.isReturning
100+
}
101+
102+
func (bi *builderInput) SetIsReturning(isReturning bool) {
103+
bi.isReturning = isReturning
104+
}
105+
95106
func (bi *builderInput) GetTableInsertionContainer() (tableinsertioncontainer.TableInsertionContainer, bool) {
96107
return bi.tableInsertionContainer, bi.tableInsertionContainer != nil
97108
}

internal/stackql/planbuilder/plan_builder.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/stackql/any-sdk/anysdk"
1111

1212
"github.com/stackql/any-sdk/pkg/logging"
13-
"github.com/stackql/any-sdk/pkg/streaming"
1413
"github.com/stackql/stackql/internal/stackql/acid/txn_context"
1514
"github.com/stackql/stackql/internal/stackql/astanalysis/routeanalysis"
1615
"github.com/stackql/stackql/internal/stackql/handler"
@@ -954,13 +953,11 @@ func (pgb *standardPlanGraphBuilder) handleInsert(pbi planbuilderinput.PlanBuild
954953
if !isAwait {
955954
bldr = returningBldr
956955
} else {
957-
rhsBldr := primitivebuilder.NewSingleSelect(
958-
pgb.planGraphHolder,
959-
handlerCtx,
956+
rhsBldr := primitivebuilder.NewSingleAcquireAndSelect(
957+
bldrInput,
958+
primitiveGenerator.GetPrimitiveComposer().GetInsertPreparedStatementCtx(),
960959
primitiveGenerator.GetPrimitiveComposer().GetSelectPreparedStatementCtx(),
961-
[]tableinsertioncontainer.TableInsertionContainer{rc},
962960
nil,
963-
streaming.NewNopMapStream(),
964961
)
965962
bldr = primitivebuilder.NewDependencySubDAGBuilder(
966963
pgb.planGraphHolder,

internal/stackql/primitivebuilder/async_compose.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ func composeAsyncMonitor(
1515
prov provider.IProvider,
1616
method anysdk.OperationStore,
1717
commentDirectives sqlparser.CommentDirectives,
18+
isReturning bool,
1819
) (primitive.IPrimitive, error) {
19-
asm, err := NewAsyncMonitor(handlerCtx, prov, method)
20+
asm, err := NewAsyncMonitor(handlerCtx, prov, method, isReturning)
2021
if err != nil {
2122
return nil, err
2223
}
@@ -31,7 +32,7 @@ func composeAsyncMonitor(
3132
handlerCtx.GetOutfile(),
3233
handlerCtx.GetOutErrFile(),
3334
)
34-
primitive, err := asm.GetMonitorPrimitive(prov, method, precursor, pl, commentDirectives)
35+
primitive, err := asm.GetMonitorPrimitive(prov, method, precursor, pl, commentDirectives, isReturning)
3536
if err != nil {
3637
return nil, err
3738
}

internal/stackql/primitivebuilder/asyncmonitor.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type IAsyncMonitor interface {
2222
precursor primitive.IPrimitive,
2323
initialCtx primitive.IPrimitiveCtx,
2424
comments sqlparser.CommentDirectives,
25+
isReturning bool,
2526
) (primitive.IPrimitive, error)
2627
}
2728

@@ -120,11 +121,12 @@ func NewAsyncMonitor(
120121
handlerCtx handler.HandlerContext,
121122
prov provider.IProvider,
122123
op anysdk.OperationStore,
124+
isReturning bool,
123125
) (IAsyncMonitor, error) {
124126
//nolint:gocritic //TODO: refactor
125127
switch prov.GetProviderString() {
126128
case "google":
127-
return newGoogleAsyncMonitor(handlerCtx, prov, op, prov.GetVersion())
129+
return newGoogleAsyncMonitor(handlerCtx, prov, op, prov.GetVersion(), isReturning)
128130
}
129131
return nil, fmt.Errorf(
130132
"async operation monitor for provider = '%s', api version = '%s' currently not supported",
@@ -136,6 +138,7 @@ func newGoogleAsyncMonitor(
136138
prov provider.IProvider,
137139
op anysdk.OperationStore,
138140
version string, //nolint:unparam // TODO: refactor
141+
isReturning bool,
139142
) (IAsyncMonitor, error) {
140143
//nolint:gocritic //TODO: refactor
141144
switch version {
@@ -160,11 +163,12 @@ func (gm *DefaultGoogleAsyncMonitor) GetMonitorPrimitive(
160163
precursor primitive.IPrimitive,
161164
initialCtx primitive.IPrimitiveCtx,
162165
comments sqlparser.CommentDirectives,
166+
isReturning bool,
163167
) (primitive.IPrimitive, error) {
164168
//nolint:gocritic,staticcheck //TODO: refactor
165169
switch strings.ToLower(prov.GetVersion()) {
166170
default:
167-
return gm.getV1Monitor(prov, op, precursor, initialCtx, comments)
171+
return gm.getV1Monitor(prov, op, precursor, initialCtx, comments, isReturning)
168172
}
169173
}
170174

@@ -174,6 +178,7 @@ func (gm *DefaultGoogleAsyncMonitor) getV1Monitor(
174178
precursor primitive.IPrimitive,
175179
initialCtx primitive.IPrimitiveCtx,
176180
comments sqlparser.CommentDirectives,
181+
isReturning bool,
177182
) (primitive.IPrimitive, error) {
178183
provider, providerErr := prov.GetProvider()
179184
if providerErr != nil {
@@ -186,6 +191,7 @@ func (gm *DefaultGoogleAsyncMonitor) getV1Monitor(
186191
precursor,
187192
initialCtx,
188193
comments,
194+
isReturning,
189195
)
190196
if exPrepErr != nil {
191197
return nil, exPrepErr

internal/stackql/primitivebuilder/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (ss *Delete) Build() error {
9393
primitive_context.NewPrimitiveContext(),
9494
)
9595
if ss.isAwait {
96-
deletePrimitive, err = composeAsyncMonitor(handlerCtx, deletePrimitive, prov, method, nil)
96+
deletePrimitive, err = composeAsyncMonitor(handlerCtx, deletePrimitive, prov, method, nil, false)
9797
}
9898
if err != nil {
9999
return err

internal/stackql/primitivebuilder/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (ss *Exec) Build() error {
174174
ss.graph.CreatePrimitiveNode(execPrimitive)
175175
return nil
176176
}
177-
pr, err := composeAsyncMonitor(handlerCtx, execPrimitive, prov, m, nil)
177+
pr, err := composeAsyncMonitor(handlerCtx, execPrimitive, prov, m, nil, false) // returning hardcoded to false for now
178178
if err != nil {
179179
return err
180180
}

internal/stackql/primitivebuilder/generic_http_reversal.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type genericHTTPReversal struct {
2525
op anysdk.OperationStore
2626
commentDirectives sqlparser.CommentDirectives
2727
isAwait bool
28+
isReturning bool
2829
verb string // may be "insert" or "update"
2930
inputAlias string
3031
isUndo bool
@@ -206,7 +207,8 @@ func (gh *genericHTTPReversal) Build() error {
206207
if err != nil {
207208
return internaldto.NewErroneousExecutorOutput(err)
208209
}
209-
execPrim, execErr := composeAsyncMonitor(handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives)
210+
execPrim, execErr := composeAsyncMonitor(
211+
handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives, gh.isReturning)
210212
if execErr != nil {
211213
return internaldto.NewErroneousExecutorOutput(execErr)
212214
}

internal/stackql/primitivebuilder/generic_http_stream_input.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type genericHTTPStreamInput struct {
3232
dependencyNode primitivegraph.PrimitiveNode
3333
parserNode sqlparser.SQLNode
3434
isAwait bool
35+
isReturning bool
3536
verb string // may be "insert" or "update"
3637
inputAlias string
3738
isUndo bool
@@ -70,6 +71,7 @@ func newGenericHTTPStreamInput(
7071
commentDirectives: commentDirectives,
7172
dependencyNode: dependencyNode,
7273
isAwait: builderInput.IsAwait(),
74+
isReturning: builderInput.IsReturning(),
7375
verb: builderInput.GetVerb(),
7476
inputAlias: builderInput.GetInputAlias(),
7577
isUndo: builderInput.IsUndo(),
@@ -357,7 +359,8 @@ func (gh *genericHTTPStreamInput) Build() error {
357359
if err != nil {
358360
return internaldto.NewErroneousExecutorOutput(err)
359361
}
360-
execPrim, execErr := composeAsyncMonitor(handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives)
362+
execPrim, execErr := composeAsyncMonitor(
363+
handlerCtx, dependentInsertPrimitive, prov, m, commentDirectives, gh.isReturning)
361364
if execErr != nil {
362365
return internaldto.NewErroneousExecutorOutput(execErr)
363366
}

internal/stackql/primitivebuilder/insert_or_update.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func (ss *insertOrUpdate) Build() error {
3838
switch node := node.(type) {
3939
case *sqlparser.Insert:
4040
mutableInput.SetVerb("insert")
41+
if len(node.SelectExprs) > 0 {
42+
mutableInput.SetIsReturning(true)
43+
}
4144
case *sqlparser.Update:
4245
mutableInput.SetVerb("update")
4346
default:

0 commit comments

Comments
 (0)