Skip to content

Commit b08bfb7

Browse files
authored
change uniq operator count field type to int64 (#6472)
With the -c flag, the uniq operator produces records with a uint64 field named count. Change the field type to int64.
1 parent cb6bd5b commit b08bfb7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This operator is most often used with [`cut`](cut.md) and [`sort`](sort.md) to f
1717
duplicate values.
1818

1919
When run with the `-c` option, each value is output as a record with the
20-
type signature `{value:any,count:uint64}`, where the `value` field contains the
20+
type signature `{value:any,count:int64}`, where the `value` field contains the
2121
unique value and the `count` field indicates the number of consecutive duplicates
2222
that occurred in the input for that output value.
2323

@@ -52,9 +52,9 @@ uniq -c
5252
2
5353
3
5454
# expected output
55-
{value:1,count:1::uint64}
56-
{value:2,count:2::uint64}
57-
{value:3,count:1::uint64}
55+
{value:1,count:1}
56+
{value:2,count:2}
57+
{value:3,count:1}
5858
```
5959

6060
---

runtime/sam/op/uniq/uniq.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Op struct {
1414
parent sbuf.Puller
1515
builder scode.Builder
1616
cflag bool
17-
count uint64
17+
count int64
1818
last *super.Value
1919
eos bool
2020
}
@@ -31,10 +31,10 @@ func (o *Op) wrap(t *super.Value) super.Value {
3131
if o.cflag {
3232
o.builder.Reset()
3333
o.builder.Append(t.Bytes())
34-
o.builder.Append(super.EncodeUint(o.count))
34+
o.builder.Append(super.EncodeInt(o.count))
3535
typ := o.rctx.Sctx.MustLookupTypeRecord([]super.Field{
3636
super.NewField("value", t.Type()),
37-
super.NewField("count", super.TypeUint64),
37+
super.NewField("count", super.TypeInt64),
3838
})
3939
return super.NewValue(typ, o.builder.Bytes()).Copy()
4040
}

runtime/ztests/op/uniq.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ input: |
88
{x:1}
99
1010
output: |
11-
{value:1,count:2::uint64}
12-
{value:{x:1},count:1::uint64}
11+
{value:1,count:2}
12+
{value:{x:1},count:1}

0 commit comments

Comments
 (0)