Skip to content

Commit

Permalink
fixed supported column types
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzhichang committed Jul 26, 2022
1 parent 86311cd commit e6f8397
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 30 deletions.
35 changes: 18 additions & 17 deletions model/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ const (
Int16
Int32
Int64
Uint8
Uint16
Uint32
Uint64
UInt8
UInt16
UInt32
UInt64
Float32
Float64
Decimal
Expand All @@ -49,6 +49,7 @@ var (
typeInfo map[string]TypeInfo
)

// GetTypeName returns the column type in ClickHouse
func GetTypeName(typ int) (name string) {
switch typ {
case Bool:
Expand All @@ -61,14 +62,14 @@ func GetTypeName(typ int) (name string) {
name = "Int32"
case Int64:
name = "Int64"
case Uint8:
name = "Uint8"
case Uint16:
name = "Uint16"
case Uint32:
name = "Uint32"
case Uint64:
name = "Uint64"
case UInt8:
name = "UInt8"
case UInt16:
name = "UInt16"
case UInt32:
name = "UInt32"
case UInt64:
name = "UInt64"
case Float32:
name = "Float32"
case Float64:
Expand Down Expand Up @@ -101,13 +102,13 @@ func GetValueByType(metric Metric, cwt *ColumnWithType) (val interface{}) {
val = metric.GetInt32(name, cwt.Nullable)
case Int64:
val = metric.GetInt64(name, cwt.Nullable)
case Uint8:
case UInt8:
val = metric.GetUint8(name, cwt.Nullable)
case Uint16:
case UInt16:
val = metric.GetUint16(name, cwt.Nullable)
case Uint32:
case UInt32:
val = metric.GetUint32(name, cwt.Nullable)
case Uint64:
case UInt64:
val = metric.GetUint64(name, cwt.Nullable)
case Float32:
val = metric.GetFloat32(name, cwt.Nullable)
Expand Down Expand Up @@ -159,7 +160,7 @@ func WhichType(typ string) (dataType int, nullable bool, array bool) {

func init() {
typeInfo = make(map[string]TypeInfo)
for _, t := range []int{Bool, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Float32, Float64, DateTime, String} {
for _, t := range []int{Bool, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64, DateTime, String} {
tn := GetTypeName(t)
typeInfo[tn] = TypeInfo{Type: t}
nullTn := fmt.Sprintf("Nullable(%s)", tn)
Expand Down
8 changes: 4 additions & 4 deletions parser/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ func (c *CsvMetric) GetArray(key string, typ int) (val interface{}) {
val = GjsonIntArray[int32](array, math.MinInt32, math.MaxInt32)
case model.Int64:
val = GjsonIntArray[int64](array, math.MinInt64, math.MaxInt64)
case model.Uint8:
case model.UInt8:
val = GjsonUintArray[uint8](array, math.MaxUint8)
case model.Uint16:
case model.UInt16:
val = GjsonUintArray[uint16](array, math.MaxUint16)
case model.Uint32:
case model.UInt32:
val = GjsonUintArray[uint32](array, math.MaxUint32)
case model.Uint64:
case model.UInt64:
val = GjsonUintArray[uint64](array, math.MaxUint64)
case model.Float32:
val = GjsonFloatArray[float32](array, math.MaxFloat32)
Expand Down
8 changes: 4 additions & 4 deletions parser/fastjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ func (c *FastjsonMetric) GetArray(key string, typ int) (val interface{}) {
val = FastjsonIntArray[int32](array, math.MinInt32, math.MaxInt32)
case model.Int64:
val = FastjsonIntArray[int64](array, math.MinInt64, math.MaxInt64)
case model.Uint8:
case model.UInt8:
val = FastjsonUintArray[uint8](array, math.MaxUint8)
case model.Uint16:
case model.UInt16:
val = FastjsonUintArray[uint16](array, math.MaxUint16)
case model.Uint32:
case model.UInt32:
val = FastjsonUintArray[uint32](array, math.MaxUint32)
case model.Uint64:
case model.UInt64:
val = FastjsonUintArray[uint64](array, math.MaxUint64)
case model.Float32:
val = FastjsonFloatArray[float32](array, math.MaxFloat32)
Expand Down
8 changes: 4 additions & 4 deletions parser/gjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ func (c *GjsonMetric) GetArray(key string, typ int) (val interface{}) {
val = GjsonIntArray[int32](array, math.MinInt32, math.MaxInt32)
case model.Int64:
val = GjsonIntArray[int64](array, math.MinInt64, math.MaxInt64)
case model.Uint8:
case model.UInt8:
val = GjsonUintArray[uint8](array, math.MaxUint8)
case model.Uint16:
case model.UInt16:
val = GjsonUintArray[uint16](array, math.MaxUint16)
case model.Uint32:
case model.UInt32:
val = GjsonUintArray[uint32](array, math.MaxUint32)
case model.Uint64:
case model.UInt64:
val = GjsonUintArray[uint64](array, math.MaxUint64)
case model.Float32:
val = GjsonFloatArray[float32](array, math.MaxFloat32)
Expand Down
2 changes: 1 addition & 1 deletion task/sharding.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewShardingPolicy(shardingKey string, shardingStripe uint64, dims []*model.
}
colSeq = i
switch dim.Type {
case model.Int8, model.Int16, model.Int32, model.Int64, model.Uint8, model.Uint16, model.Uint32, model.Uint64, model.Float32, model.Float64, model.Decimal, model.DateTime:
case model.Int8, model.Int16, model.Int32, model.Int64, model.UInt8, model.UInt16, model.UInt32, model.UInt64, model.Float32, model.Float64, model.Decimal, model.DateTime:
//numerical
if policy.stripe <= 0 {
policy.stripe = uint64(1)
Expand Down

0 comments on commit e6f8397

Please sign in to comment.