rename field types
This commit is contained in:
@@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
TypeBoolean = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_BOOLEAN}}
|
||||
TypeInt32 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_INTEGER}}
|
||||
Type64 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_LONG}}
|
||||
TypeFloat32 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_FLOAT}}
|
||||
TypeFloat64 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_DOUBLE}}
|
||||
TypeBoolean = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_BOOL}}
|
||||
TypeInt32 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_INT32}}
|
||||
TypeInt64 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_INT64}}
|
||||
TypeFloat32 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_FLOAT32}}
|
||||
TypeFloat64 = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_FLOAT64}}
|
||||
TypeBytes = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_BYTES}}
|
||||
TypeString = &schema_pb.Type{Kind: &schema_pb.Type_ScalarType{schema_pb.ScalarType_STRING}}
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ func TestEnumScalarType(t *testing.T) {
|
||||
enum ScalarType
|
||||
expected int32
|
||||
}{
|
||||
{"Boolean", ScalarType_BOOLEAN, 0},
|
||||
{"Boolean", ScalarType_BOOL, 0},
|
||||
{"Integer", ScalarType_INTEGER, 1},
|
||||
{"Long", ScalarType_LONG, 3},
|
||||
{"Float", ScalarType_FLOAT, 4},
|
||||
|
||||
@@ -21,7 +21,7 @@ func reflectTypeToSchemaType(t reflect.Type) *schema_pb.Type {
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32:
|
||||
return TypeInt32
|
||||
case reflect.Int64:
|
||||
return Type64
|
||||
return TypeInt64
|
||||
case reflect.Float32:
|
||||
return TypeFloat32
|
||||
case reflect.Float64:
|
||||
|
||||
@@ -19,8 +19,8 @@ func TestToParquetLevels(t *testing.T) {
|
||||
name: "nested type",
|
||||
args: args{
|
||||
RecordTypeBegin().
|
||||
WithField("ID", Type64).
|
||||
WithField("CreatedAt", Type64).
|
||||
WithField("ID", TypeInt64).
|
||||
WithField("CreatedAt", TypeInt64).
|
||||
WithRecordField("Person",
|
||||
RecordTypeBegin().
|
||||
WithField("zName", TypeString).
|
||||
|
||||
@@ -45,15 +45,15 @@ func toParquetFieldTypeList(listType *schema_pb.ListType) (parquet.Node, error)
|
||||
|
||||
func toParquetFieldTypeScalar(scalarType schema_pb.ScalarType) (parquet.Node, error) {
|
||||
switch scalarType {
|
||||
case schema_pb.ScalarType_BOOLEAN:
|
||||
case schema_pb.ScalarType_BOOL:
|
||||
return parquet.Leaf(parquet.BooleanType), nil
|
||||
case schema_pb.ScalarType_INTEGER:
|
||||
case schema_pb.ScalarType_INT32:
|
||||
return parquet.Leaf(parquet.Int32Type), nil
|
||||
case schema_pb.ScalarType_LONG:
|
||||
case schema_pb.ScalarType_INT64:
|
||||
return parquet.Leaf(parquet.Int64Type), nil
|
||||
case schema_pb.ScalarType_FLOAT:
|
||||
case schema_pb.ScalarType_FLOAT32:
|
||||
return parquet.Leaf(parquet.FloatType), nil
|
||||
case schema_pb.ScalarType_DOUBLE:
|
||||
case schema_pb.ScalarType_FLOAT64:
|
||||
return parquet.Leaf(parquet.DoubleType), nil
|
||||
case schema_pb.ScalarType_BYTES:
|
||||
return parquet.Leaf(parquet.ByteArrayType), nil
|
||||
|
||||
@@ -66,15 +66,15 @@ func toScalarValue(scalarType schema_pb.ScalarType, levels *ParquetLevels, value
|
||||
return nil, valueIndex, nil
|
||||
}
|
||||
switch scalarType {
|
||||
case schema_pb.ScalarType_BOOLEAN:
|
||||
case schema_pb.ScalarType_BOOL:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_BoolValue{BoolValue: value.Boolean()}}, valueIndex+1, nil
|
||||
case schema_pb.ScalarType_INTEGER:
|
||||
case schema_pb.ScalarType_INT32:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_Int32Value{Int32Value: value.Int32()}}, valueIndex+1, nil
|
||||
case schema_pb.ScalarType_LONG:
|
||||
case schema_pb.ScalarType_INT64:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_Int64Value{Int64Value: value.Int64()}}, valueIndex+1, nil
|
||||
case schema_pb.ScalarType_FLOAT:
|
||||
case schema_pb.ScalarType_FLOAT32:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_FloatValue{FloatValue: value.Float()}}, valueIndex+1, nil
|
||||
case schema_pb.ScalarType_DOUBLE:
|
||||
case schema_pb.ScalarType_FLOAT64:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_DoubleValue{DoubleValue: value.Double()}}, valueIndex+1, nil
|
||||
case schema_pb.ScalarType_BYTES:
|
||||
return &schema_pb.Value{Kind: &schema_pb.Value_BytesValue{BytesValue: value.ByteArray()}}, valueIndex+1, nil
|
||||
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
func TestWriteReadParquet(t *testing.T) {
|
||||
// create a schema_pb.RecordType
|
||||
recordType := RecordTypeBegin().
|
||||
WithField("ID", Type64).
|
||||
WithField("CreatedAt", Type64).
|
||||
WithField("ID", TypeInt64).
|
||||
WithField("CreatedAt", TypeInt64).
|
||||
WithRecordField("Person",
|
||||
RecordTypeBegin().
|
||||
WithField("zName", TypeString).
|
||||
|
||||
Reference in New Issue
Block a user