Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
27a8ae1
fix: support scalar subquery in INNER JOIN ON condition
aunjgr Jul 1, 2026
79ca6f1
feat: stream local scans to Sirius
aunjgr Aug 25, 2026
1bfb8af
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 25, 2026
44a2e83
Merge branch 'main' into feature/27586-stream-input
mergify[bot] Aug 25, 2026
1de258b
fix: close Sirius stream input failure paths
aunjgr Aug 25, 2026
49c9f41
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 25, 2026
af20802
test: cover Sirius stream compile context
aunjgr Aug 25, 2026
8869b4f
fix: reject incompatible Sirius native input types
aunjgr Aug 25, 2026
55caa53
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 25, 2026
0d0e6ac
feat: use MatrixOne native sidecar results
aunjgr Aug 26, 2026
1c0af66
Merge remote-tracking branch 'origin/main' into feature/27586-stream-…
aunjgr Aug 26, 2026
aca3342
fix: retire streamed inputs after result EOF
aunjgr Aug 26, 2026
d42ac51
fix: use moerr for Sirius completion sentinel
aunjgr Aug 26, 2026
4dca992
fix: add cause to streamed cleanup timeout
aunjgr Aug 26, 2026
8e287bc
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
9f8cf3e
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
294522a
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
758a52a
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
133ff93
fix: bound native sidecar result work
aunjgr Aug 26, 2026
f44446a
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
9570510
fix: satisfy native result schema lint
aunjgr Aug 26, 2026
4ba883e
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
c15c488
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 26, 2026
fb9651e
Merge branch 'main' into feature/27586-stream-input
aunjgr Aug 28, 2026
ce36e74
docs: define Sirius streamed input contract
aunjgr Aug 28, 2026
76d596b
docs: make streamed input demand driven
aunjgr Aug 28, 2026
795b2a0
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 28, 2026
cca389e
docs: bound streamed input execution
aunjgr Aug 28, 2026
d071b23
Merge remote-tracking branch 'upstream/main' into feature/27586-strea…
aunjgr Aug 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
670 changes: 670 additions & 0 deletions docs/design/sirius-streamed-input.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pkg/container/vector/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3243,6 +3243,11 @@ func (v *Vector) IsConst() bool {
return v.class == CONSTANT
}

// IsFlat reports whether the vector stores one physical value per logical row.
func (v *Vector) IsFlat() bool {
return v.class == FLAT
}

func (v *Vector) IsGrouping() bool {
return v.length > 0 &&
v.length == v.gsp.Count() &&
Expand Down
3 changes: 3 additions & 0 deletions pkg/frontend/computation_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,9 @@ func compileStatementContexts(
) (requestCtx, compileCtx context.Context) {
requestCtx = perfcounter.AttachCompilePlanMarkKey(ctx, crs)
if siriusStatementSelected(sql, stmt) {
if strings.HasPrefix(strings.ToUpper(strings.TrimSpace(sql)), sidecarStreamHintPrefix) {
return requestCtx, compile.WithSiriusStreamOffload(requestCtx)
}
return requestCtx, compile.WithSiriusOffload(requestCtx)
}
return requestCtx, requestCtx
Expand Down
1 change: 1 addition & 0 deletions pkg/frontend/computation_wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,7 @@ func TestCompileStatementContextsPreserveCounterWithoutLeakingSelection(t *testi
separateChild bool
}{
{name: "selected", sql: "/*+ SIDECAR */ select 1", separateChild: true},
{name: "stream selected", sql: "/*+ SIDECAR STREAM */ select 1", separateChild: true},
{name: "unselected", sql: "select 1"},
} {
t.Run(test.name, func(t *testing.T) {
Expand Down
13 changes: 10 additions & 3 deletions pkg/frontend/sidecar_offload.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ import (
)

const (
sidecarHintPrefix = "/*+ SIDECAR */"
sidecarGPUHintPrefix = "/*+ SIDECAR GPU */"
sidecarMaxResponseSize = 512 << 20 // 512 MB
sidecarHintPrefix = "/*+ SIDECAR */"
sidecarGPUHintPrefix = "/*+ SIDECAR GPU */"
sidecarStreamHintPrefix = "/*+ SIDECAR STREAM */"
sidecarMaxResponseSize = 512 << 20 // 512 MB
)

// errSidecarNotConfigured is a sentinel indicating sidecar offload should
Expand Down Expand Up @@ -94,6 +95,9 @@ func getManifestBaseURL() string {
func isSidecarQuery(sql string) (bool, bool) {
trimmed := strings.TrimSpace(sql)
upper := strings.ToUpper(trimmed)
if strings.HasPrefix(upper, sidecarStreamHintPrefix) {
return true, true
}
if strings.HasPrefix(upper, sidecarGPUHintPrefix) {
return true, true
}
Expand All @@ -108,6 +112,9 @@ func isSidecarQuery(sql string) (bool, bool) {
func stripSidecarHint(sql string) string {
trimmed := strings.TrimSpace(sql)
upper := strings.ToUpper(trimmed)
if strings.HasPrefix(upper, sidecarStreamHintPrefix) {
return strings.TrimSpace(trimmed[len(sidecarStreamHintPrefix):])
}
if strings.HasPrefix(upper, sidecarGPUHintPrefix) {
return strings.TrimSpace(trimmed[len(sidecarGPUHintPrefix):])
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/frontend/sidecar_offload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestIsSidecarQuery(t *testing.T) {
assert.True(t, isSidecar)
assert.True(t, useGPU)

isSidecar, useGPU = isSidecarQuery("/*+ SIDECAR STREAM */ SELECT * FROM t")
assert.True(t, isSidecar)
assert.True(t, useGPU)

// Non-sidecar queries
isSidecar, _ = isSidecarQuery("SELECT * FROM t")
assert.False(t, isSidecar)
Expand All @@ -73,6 +77,7 @@ func TestStripSidecarHint(t *testing.T) {
assert.Equal(t, "SELECT * FROM t", stripSidecarHint(" /*+ SIDECAR */ SELECT * FROM t"))
assert.Equal(t, "SELECT * FROM t", stripSidecarHint("/*+ SIDECAR GPU */ SELECT * FROM t"))
assert.Equal(t, "SELECT * FROM t", stripSidecarHint(" /*+ sidecar gpu */ SELECT * FROM t"))
assert.Equal(t, "SELECT * FROM t", stripSidecarHint("/*+ SIDECAR STREAM */ SELECT * FROM t"))
assert.Equal(t, "SELECT * FROM t", stripSidecarHint("SELECT * FROM t"))
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/colexec/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ func (output *Output) Call(proc *process.Process) (vm.CallResult, error) {
result.Status = vm.ExecStop
return result, err
}
if output.stop != nil && output.stop() {
result.Status = vm.ExecStop
}

// TODO: analyzer.Output(result.Batch)
return result, nil
Expand Down Expand Up @@ -140,6 +143,9 @@ func (output *Output) Call(proc *process.Process) (vm.CallResult, error) {
result.Status = vm.ExecStop
return result, err
}
if output.stop != nil && output.stop() {
result.Status = vm.ExecStop
}

result.Batch = bat
// same as nonBlock
Expand Down
40 changes: 40 additions & 0 deletions pkg/sql/colexec/output/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,46 @@ func TestOutputCallbackCPUIsNotOutputWait(t *testing.T) {
require.Zero(t, proc.Mp().CurrNB())
}

func TestOutputCanStopOneProducerAfterSuccessfulCallback(t *testing.T) {
proc := testutil.NewProcessWithMPool(t, "", mpool.MustNewZero())
calls := 0
arg := NewArgument().WithFunc(func(_ *batch.Batch, _ *perfcounter.CounterSet) error {
calls++
return nil
}).WithShouldStop(func() bool { return calls == 1 })
require.NoError(t, arg.Prepare(proc))
first := newBatch([]types.Type{types.T_int8.ToType()}, proc, 1)
second := newBatch([]types.Type{types.T_int8.ToType()}, proc, 1)
resetChildren(arg, []*batch.Batch{first, second})
result, err := vm.Exec(arg, proc)
require.NoError(t, err)
require.Equal(t, vm.ExecStop, result.Status)
require.Equal(t, 1, calls)
arg.GetChildren(0).Free(proc, false, nil)
arg.Free(proc, false, nil)
proc.Free()
}

func TestBlockingOutputCanStopAfterFirstReleasedBatch(t *testing.T) {
proc := testutil.NewProcessWithMPool(t, "", mpool.MustNewZero())
calls := 0
arg := NewArgument().WithBlock(true).WithFunc(func(_ *batch.Batch, _ *perfcounter.CounterSet) error {
calls++
return nil
}).WithShouldStop(func() bool { return calls == 1 })
require.NoError(t, arg.Prepare(proc))
first := newBatch([]types.Type{types.T_int8.ToType()}, proc, 1)
second := newBatch([]types.Type{types.T_int8.ToType()}, proc, 1)
resetChildren(arg, []*batch.Batch{first, second})
result, err := vm.Exec(arg, proc)
require.NoError(t, err)
require.Equal(t, vm.ExecStop, result.Status)
require.Equal(t, 1, calls)
arg.GetChildren(0).Free(proc, false, nil)
arg.Free(proc, false, nil)
proc.Free()
}

// create a new block based on the type information
func newBatch(ts []types.Type, proc *process.Process, rows int64) *batch.Batch {
return testutil.NewBatch(ts, false, int(rows), proc.Mp())
Expand Down
9 changes: 9 additions & 0 deletions pkg/sql/colexec/output/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Output struct {

Data interface{}
Func func(*batch.Batch, *perfcounter.CounterSet) error
stop func() bool

// IsAdaptive enables the adaptive vector search fallback mechanism.
// When set to true and the query completes with zero results (rowCount == 0),
Expand Down Expand Up @@ -99,6 +100,14 @@ func (output *Output) WithFunc(Func func(*batch.Batch, *perfcounter.CounterSet)
return output
}

// WithShouldStop lets a sink end only its own producer pipeline after a
// successful callback. It is used when a remote consumer declares that this
// input relation is no longer needed; nil preserves the ordinary output path.
func (output *Output) WithShouldStop(stop func() bool) *Output {
output.stop = stop
return output
}

// WithBlocck set the output is blocked. If true output will block the current pipeline, and cache
// all input batches. And wait for all the input's batch to be locked before outputting the cached batch
// to the downstream operator.
Expand Down
4 changes: 3 additions & 1 deletion pkg/sql/compile/compile2.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ func (c *Compile) Run(_ uint64) (queryResult *util2.RunResult, err error) {
queryResult = &util2.RunResult{}
v2.TxnStatementTotalCounter.Inc()
if c.siriusRead != nil {
err = c.runSiriusRead(execTopContext)
err = c.runSiriusRead(execTopContext, func(snapshot mpool.AllocationAccountTerminalSnapshot) {
resourceRecorder.recordAllocationAccountTerminal(snapshot)
})
return queryResult, err
}
attemptStart := time.Now()
Expand Down
Loading
Loading