Skip to content

Commit 21aa0c0

Browse files
authored
change count operator output field to int64 (#6463)
1 parent a69e5cc commit 21aa0c0

File tree

4 files changed

+26
-26
lines changed

4 files changed

+26
-26
lines changed

book/src/super-sql/operators/count.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ count
3535
{foo:"bar",a:true}
3636
{foo:"baz",b:false}
3737
# expected output
38-
{that:{foo:"bar",a:true},count:1::uint64}
39-
{that:{foo:"baz",b:false},count:2::uint64}
38+
{that:{foo:"bar",a:true},count:1}
39+
{that:{foo:"baz",b:false},count:2}
4040
```
4141

4242
---
@@ -50,9 +50,9 @@ count {c}
5050
"b"
5151
"c"
5252
# expected output
53-
{c:1::uint64}
54-
{c:2::uint64}
55-
{c:3::uint64}
53+
{c:1}
54+
{c:2}
55+
{c:3}
5656
```
5757

5858
---
@@ -65,8 +65,8 @@ count {...this,c}
6565
{foo:"bar",a:true}
6666
{foo:"baz",b:false}
6767
# expected output
68-
{foo:"bar",a:true,c:1::uint64}
69-
{foo:"baz",b:false,c:2::uint64}
68+
{foo:"bar",a:true,c:1}
69+
{foo:"baz",b:false,c:2}
7070
```
7171

7272
---
@@ -79,6 +79,6 @@ count {third_foo_char:foo[2:3],c}
7979
{foo:"bar",a:true}
8080
{foo:"baz",b:false}
8181
# expected output
82-
{third_foo_char:"r",c:1::uint64}
83-
{third_foo_char:"z",c:2::uint64}
82+
{third_foo_char:"r",c:1}
83+
{third_foo_char:"z",c:2}
8484
```

runtime/sam/op/count/count.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Op struct {
1010
parent sbuf.Puller
1111
alias string
1212
expr expr.Evaluator
13-
count uint64
13+
count int64
1414
}
1515

1616
func New(sctx *super.Context, parent sbuf.Puller, alias string, in expr.Evaluator) (*Op, error) {
@@ -44,5 +44,5 @@ func (e evalfunc) Eval(this super.Value) super.Value { return e(this) }
4444

4545
func (o *Op) evalCount(_ super.Value) super.Value {
4646
o.count++
47-
return super.NewUint64(o.count)
47+
return super.NewInt64(o.count)
4848
}

runtime/vam/op/count.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Count struct {
1111
parent vector.Puller
1212
alias string
1313
expr expr.Evaluator
14-
count uint64
14+
count int64
1515
}
1616

1717
func NewCount(sctx *super.Context, parent vector.Puller, alias string, in expr.Evaluator) *Count {
@@ -39,10 +39,10 @@ type evalfunc func(vector.Any) vector.Any
3939
func (e evalfunc) Eval(this vector.Any) vector.Any { return e(this) }
4040

4141
func (o *Count) evalCount(in vector.Any) vector.Any {
42-
counts := make([]uint64, in.Len())
42+
counts := make([]int64, in.Len())
4343
for i := range in.Len() {
4444
o.count++
4545
counts[i] = o.count
4646
}
47-
return vector.NewUint(super.TypeUint64, counts, bitvec.Zero)
47+
return vector.NewInt(super.TypeInt64, counts, bitvec.Zero)
4848
}

runtime/ztests/op/count.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ vector: true
2121
outputs:
2222
- name: stdout
2323
data: |
24-
{that:{x:1},count:1::uint64}
25-
{that:{x:2},count:2::uint64}
24+
{that:{x:1},count:1}
25+
{that:{x:2},count:2}
2626
// ===
27-
{count:1::uint64}
28-
{count:2::uint64}
27+
{count:1}
28+
{count:2}
2929
// ===
30-
{x:1,row_number:1::uint64}
31-
{x:2,row_number:2::uint64}
30+
{x:1,row_number:1}
31+
{x:2,row_number:2}
3232
// ===
33-
{x:1,row_number:1::uint64}
34-
{x:2,row_number:2::uint64}
33+
{x:1,row_number:1}
34+
{x:2,row_number:2}
3535
// ===
36-
{val:1,c:1::uint64}
37-
{val:2,c:2::uint64}
38-
{val:3,c:1::uint64}
39-
{val:4,c:2::uint64}
36+
{val:1,c:1}
37+
{val:2,c:2}
38+
{val:3,c:1}
39+
{val:4,c:2}
4040
- name: stderr
4141
data: |
4242
type mismatch at line 1, column 32:

0 commit comments

Comments
 (0)