Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion book/src/super-sql/functions/records/unflatten.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ _Flatten to unflatten_
```mdtest-spq
# spq
unnest flatten(this) into (
key[1] != "rm"
key[0] != "rm"
| values collect(this)
)
| values unflatten(this)
Expand Down
2 changes: 1 addition & 1 deletion book/src/super-sql/functions/strings/upper.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ values upper(this)
```mdtest-spq
# spq
fn capitalize(str): (
upper(str[1:2]) + str[2:]
upper(str[0:1]) + str[1:]
)
values capitalize(this)
# input
Expand Down
2 changes: 1 addition & 1 deletion book/src/super-sql/operators/unnest.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ unnest {s,a} into ( sum(a) by s )
_Unnested the elements of a record by flattening it_
```mdtest-spq
# spq
unnest {s,f:flatten(r)} into ( values {s,key:f.key[1],val:f.value} )
unnest {s,f:flatten(r)} into ( values {s,key:f.key[0],val:f.value} )
# input
{s:"foo",r:{a:1,b:2}}
{s:"bar",r:{a:3,b:4}}
Expand Down
18 changes: 13 additions & 5 deletions compiler/ast/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ type OpDecl struct {
Loc `json:"loc"`
}

type PragmaDecl struct {
Kind string `json:"kind" unpack:""`
Name *ID `json:"name"`
Expr Expr `json:"expr"`
Loc `json:"loc"`
}

type QueryDecl struct {
Kind string `json:"kind" unpack:""`
Name *ID `json:"name"`
Expand All @@ -41,8 +48,9 @@ type TypeDecl struct {
Loc `json:"loc"`
}

func (*ConstDecl) declNode() {}
func (*FuncDecl) declNode() {}
func (*OpDecl) declNode() {}
func (*QueryDecl) declNode() {}
func (*TypeDecl) declNode() {}
func (*ConstDecl) declNode() {}
func (*FuncDecl) declNode() {}
func (*OpDecl) declNode() {}
func (*PragmaDecl) declNode() {}
func (*QueryDecl) declNode() {}
func (*TypeDecl) declNode() {}
1 change: 1 addition & 0 deletions compiler/ast/unpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ var unpacker = unpack.New(
OpDecl{},
OutputOp{},
PassOp{},
PragmaDecl{},
Primitive{},
PutOp{},
Record{},
Expand Down
10 changes: 6 additions & 4 deletions compiler/dag/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type (
Kind string `json:"kind" unpack:""`
Expr Expr `json:"expr"`
Index Expr `json:"index"`
Base1 bool `json:"base1"`
}
IsNullExpr struct {
Kind string `json:"kind" unpack:""`
Expand Down Expand Up @@ -112,10 +113,11 @@ type (
Elems []VectorElem `json:"elems"`
}
SliceExpr struct {
Kind string `json:"kind" unpack:""`
Expr Expr `json:"expr"`
From Expr `json:"from"`
To Expr `json:"to"`
Kind string `json:"kind" unpack:""`
Expr Expr `json:"expr"`
From Expr `json:"from"`
To Expr `json:"to"`
Base1 bool `json:"base1"`
}
SortExpr struct {
Key Expr `json:"key"`
Expand Down
Loading