Skip to content

Commit 4a66fe0

Browse files
authored
mark int type explicitly as int64 (#332)
* mark int type explicitly as int64 fixes #330 Signed-off-by: Thomas Jungblut <[email protected]> * use 32bit truncation for parquet --------- Signed-off-by: Thomas Jungblut <[email protected]>
1 parent ca4ac3f commit 4a66fe0

File tree

14 files changed

+38
-38
lines changed

14 files changed

+38
-38
lines changed

aggregates/count.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var CountOverloads = []physical.AggregateDescriptor{
1515
}
1616

1717
type Count struct {
18-
count int
18+
count int64
1919
}
2020

2121
func NewCountPrototype() func() nodes.Aggregate {

aggregates/sum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var SumOverloads = []physical.AggregateDescriptor{
2727
}
2828

2929
type SumInt struct {
30-
sum int
30+
sum int64
3131
}
3232

3333
func NewSumIntPrototype() func() nodes.Aggregate {

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ octosql "SELECT * FROM plugins.plugins"`,
385385

386386
switch output {
387387
case "live_table", "batch_table":
388-
var limit *int
388+
var limit *int64
389389
if limitExpression != nil {
390390
val, err := (*limitExpression).Evaluate(execCtx)
391391
if err != nil {

datasources/csv/execution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (d *DatasourceExecuting) Run(ctx ExecutionContext, produce ProduceFn, metaS
7171
if octosql.Int.Is(d.fields[i].Type) == octosql.TypeRelationIs {
7272
integer, err := fastfloat.ParseInt64(str)
7373
if err == nil {
74-
values[i] = octosql.NewInt(int(integer))
74+
values[i] = octosql.NewInt(integer)
7575
continue
7676
}
7777
}

datasources/lines/execution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (d *DatasourceExecuting) Run(ctx ExecutionContext, produce ProduceFn, metaS
4545
})
4646
}
4747

48-
line := 0
48+
line := int64(0)
4949
for sc.Scan() {
5050
values := make([]octosql.Value, len(d.fields))
5151
for i := range d.fields {

datasources/parquet/reconstruct.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ func assignValue(dst *octosql.Value, src parquet.Value) error {
293293
case parquet.Boolean:
294294
*dst = octosql.NewBoolean(src.Boolean())
295295
case parquet.Int32:
296-
*dst = octosql.NewInt(int(src.Int32()))
296+
*dst = octosql.NewInt(int64(src.Int32()))
297297
case parquet.Int64:
298-
*dst = octosql.NewInt(int(src.Int64()))
298+
*dst = octosql.NewInt(src.Int64())
299299
case parquet.Int96:
300300
*dst = octosql.NewString(src.Int96().String())
301301
case parquet.Float:

execution/nodes/limit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (m *Limit) Run(ctx ExecutionContext, produce ProduceFn, metaSend MetaSendFn
3030

3131
limitNodeID := ulid.MustNew(ulid.Now(), rand.Reader).String()
3232

33-
i := 0
33+
i := int64(0)
3434
if err := m.source.Run(ctx, func(produceCtx ProduceContext, record Record) error {
3535
if err := produce(produceCtx, record); err != nil {
3636
return fmt.Errorf("couldn't produce: %w", err)

execution/nodes/order_sensitive_transform.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func (item *orderByItem) Less(than btree.Item) bool {
5858
}
5959

6060
func (o *OrderSensitiveTransform) Run(execCtx ExecutionContext, produce ProduceFn, metaSend MetaSendFn) error {
61-
var limit *int
61+
var limit *int64
6262
if o.limit != nil {
6363
val, err := (*o.limit).Evaluate(execCtx)
6464
if err != nil {
@@ -112,7 +112,7 @@ func (o *OrderSensitiveTransform) Run(execCtx ExecutionContext, produce ProduceF
112112
} else {
113113
recordCounts.Delete(itemTyped)
114114
}
115-
if limit != nil && o.noRetractionsPossible && recordCounts.Len() > *limit {
115+
if limit != nil && o.noRetractionsPossible && int64(recordCounts.Len()) > *limit {
116116
// This doesn't mean we'll always keep just the records that are needed, because tree nodes might have count > 1.
117117
// That said, it's a good approximation, and we'll definitely not lose something that we need to have.
118118
recordCounts.DeleteMax()
@@ -130,8 +130,8 @@ func (o *OrderSensitiveTransform) Run(execCtx ExecutionContext, produce ProduceF
130130
return nil
131131
}
132132

133-
func produceOrderByItems(ctx ProduceContext, recordCounts *btree.BTree, limit *int, produce ProduceFn) error {
134-
i := 0
133+
func produceOrderByItems(ctx ProduceContext, recordCounts *btree.BTree, limit *int64, produce ProduceFn) error {
134+
i := int64(0)
135135
var outErr error
136136
recordCounts.Ascend(func(item btree.Item) bool {
137137
if limit != nil && i >= *limit {

functions/functions.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,15 @@ func FunctionMap() map[string]physical.FunctionDetails {
304304
OutputType: octosql.String,
305305
Strict: true,
306306
Function: func(values []octosql.Value) (octosql.Value, error) {
307-
return octosql.NewString(strings.Repeat(values[0].Str, values[1].Int)), nil
307+
return octosql.NewString(strings.Repeat(values[0].Str, int(values[1].Int))), nil
308308
},
309309
},
310310
{
311311
ArgumentTypes: []octosql.Type{octosql.Int, octosql.String},
312312
OutputType: octosql.String,
313313
Strict: true,
314314
Function: func(values []octosql.Value) (octosql.Value, error) {
315-
return octosql.NewString(strings.Repeat(values[1].Str, values[0].Int)), nil
315+
return octosql.NewString(strings.Repeat(values[1].Str, int(values[0].Int))), nil
316316
},
317317
},
318318
},
@@ -718,7 +718,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
718718
OutputType: octosql.String,
719719
Strict: true,
720720
Function: func(values []octosql.Value) (octosql.Value, error) {
721-
if len(values[0].Str) <= values[1].Int {
721+
if int64(len(values[0].Str)) <= values[1].Int {
722722
return octosql.NewString(""), nil
723723
}
724724
return octosql.NewString(values[0].Str[values[1].Int:]), nil
@@ -729,12 +729,12 @@ func FunctionMap() map[string]physical.FunctionDetails {
729729
OutputType: octosql.String,
730730
Strict: true,
731731
Function: func(values []octosql.Value) (octosql.Value, error) {
732-
if len(values[0].Str) <= values[1].Int {
732+
if int64(len(values[0].Str)) <= values[1].Int {
733733
return octosql.NewString(""), nil
734734
}
735735
end := values[1].Int + values[2].Int
736-
if end > len(values[0].Str) {
737-
end = len(values[0].Str)
736+
if end > int64(len(values[0].Str)) {
737+
end = int64(len(values[0].Str))
738738
}
739739
return octosql.NewString(values[0].Str[values[1].Int:end]), nil
740740
},
@@ -766,7 +766,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
766766
if i == -1 {
767767
return octosql.NewNull(), nil
768768
}
769-
return octosql.NewInt(i), nil
769+
return octosql.NewInt(int64(i)), nil
770770
},
771771
},
772772
},
@@ -779,7 +779,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
779779
OutputType: octosql.Int,
780780
Strict: true,
781781
Function: func(values []octosql.Value) (octosql.Value, error) {
782-
return octosql.NewInt(len(values[0].Str)), nil
782+
return octosql.NewInt(int64(len(values[0].Str))), nil
783783
},
784784
},
785785
{
@@ -794,7 +794,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
794794
},
795795
Strict: true,
796796
Function: func(values []octosql.Value) (octosql.Value, error) {
797-
return octosql.NewInt(len(values[0].List)), nil
797+
return octosql.NewInt(int64(len(values[0].List))), nil
798798
},
799799
},
800800
{
@@ -809,7 +809,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
809809
},
810810
Strict: true,
811811
Function: func(values []octosql.Value) (octosql.Value, error) {
812-
return octosql.NewInt(len(values[0].Struct)), nil
812+
return octosql.NewInt(int64(len(values[0].Struct))), nil
813813
},
814814
},
815815
{
@@ -824,7 +824,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
824824
},
825825
Strict: true,
826826
Function: func(values []octosql.Value) (octosql.Value, error) {
827-
return octosql.NewInt(len(values[0].Tuple)), nil
827+
return octosql.NewInt(int64(len(values[0].Tuple))), nil
828828
},
829829
},
830830
},
@@ -891,7 +891,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
891891
OutputType: octosql.Int,
892892
Strict: true,
893893
Function: func(values []octosql.Value) (octosql.Value, error) {
894-
return octosql.NewInt(int(values[0].Time.Unix())), nil
894+
return octosql.NewInt(values[0].Time.Unix()), nil
895895
},
896896
},
897897
},
@@ -927,15 +927,15 @@ func FunctionMap() map[string]physical.FunctionDetails {
927927
OutputType: octosql.Int,
928928
Strict: true,
929929
Function: func(values []octosql.Value) (octosql.Value, error) {
930-
return octosql.NewInt(int(values[0].Float)), nil
930+
return octosql.NewInt(int64(values[0].Float)), nil
931931
},
932932
},
933933
{
934934
ArgumentTypes: []octosql.Type{octosql.String},
935935
OutputType: octosql.Int,
936936
Strict: true,
937937
Function: func(values []octosql.Value) (octosql.Value, error) {
938-
n, err := strconv.Atoi(values[0].Str)
938+
n, err := strconv.ParseInt(values[0].Str, 10, 64)
939939
if err != nil {
940940
log.Printf("couldn't parse string '%s' as int: %s", values[0].Str, err)
941941
return octosql.NewNull(), nil
@@ -948,7 +948,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
948948
OutputType: octosql.Int,
949949
Strict: true,
950950
Function: func(values []octosql.Value) (octosql.Value, error) {
951-
return octosql.NewInt(int(values[0].Duration)), nil
951+
return octosql.NewInt(int64(values[0].Duration)), nil
952952
},
953953
},
954954
},
@@ -1033,7 +1033,7 @@ func FunctionMap() map[string]physical.FunctionDetails {
10331033
},
10341034
Strict: true,
10351035
Function: func(values []octosql.Value) (octosql.Value, error) {
1036-
if values[1].Int >= len(values[0].List) {
1036+
if values[1].Int >= int64(len(values[0].List)) {
10371037
return octosql.NewNull(), nil
10381038
}
10391039
return values[0].List[values[1].Int], nil

octosql/values.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var ZeroValue = Value{}
1414
// Value represents a single row value. The zero value of it is conveniently NULL.
1515
type Value struct {
1616
TypeID TypeID
17-
Int int
17+
Int int64
1818
Float float64
1919
Boolean bool
2020
Str string
@@ -31,7 +31,7 @@ func NewNull() Value {
3131
}
3232
}
3333

34-
func NewInt(value int) Value {
34+
func NewInt(value int64) Value {
3535
return Value{
3636
TypeID: TypeIDInt,
3737
Int: value,

0 commit comments

Comments
 (0)