rename api

This commit is contained in:
chrislu 2024-04-28 12:40:00 -07:00
parent 5ce8f50546
commit 1a2332c257
3 changed files with 10 additions and 22 deletions

View File

@ -39,24 +39,12 @@ func (rtb *RecordTypeBuilder) SetField(name string, scalarType *schema_pb.Type)
return rtb return rtb
} }
func (rtb *RecordTypeBuilder) SetBoolField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeBoolean)
}
func (rtb *RecordTypeBuilder) SetIntegerField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeInteger)
}
func (rtb *RecordTypeBuilder) SetLongField(name string) *RecordTypeBuilder { func (rtb *RecordTypeBuilder) SetLongField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeLong) return rtb.SetField(name, TypeLong)
} }
func (rtb *RecordTypeBuilder) SetFloatField(name string) *RecordTypeBuilder { func (rtb *RecordTypeBuilder) SetFloatField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeFloat) return rtb.SetField(name, TypeFloat)
} }
func (rtb *RecordTypeBuilder) SetDoubleField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeDouble)
}
func (rtb *RecordTypeBuilder) SetBytesField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeBytes)
}
func (rtb *RecordTypeBuilder) SetStringField(name string) *RecordTypeBuilder { func (rtb *RecordTypeBuilder) SetStringField(name string) *RecordTypeBuilder {
return rtb.SetField(name, TypeString) return rtb.SetField(name, TypeString)
} }
@ -77,6 +65,6 @@ func (rtb *RecordTypeBuilder) SetListField(name string, elementType *schema_pb.T
return rtb return rtb
} }
func List(elementType *schema_pb.Type) *schema_pb.Type { func ListOf(elementType *schema_pb.Type) *schema_pb.Type {
return &schema_pb.Type{Kind: &schema_pb.Type_ListType{ListType: &schema_pb.ListType{ElementType: elementType}}} return &schema_pb.Type{Kind: &schema_pb.Type_ListType{ListType: &schema_pb.ListType{ElementType: elementType}}}
} }

View File

@ -44,7 +44,7 @@ func TestStructToSchema(t *testing.T) {
}{}, }{},
}, },
want: NewRecordTypeBuilder(). want: NewRecordTypeBuilder().
SetField("Field1", List(TypeInteger)). SetField("Field1", ListOf(TypeInteger)).
SetField("Field2", TypeString). SetField("Field2", TypeString).
Build(), Build(),
}, },
@ -97,7 +97,7 @@ func TestStructToSchema(t *testing.T) {
SetField("Field1", TypeInteger). SetField("Field1", TypeInteger).
SetRecordField("Field2", NewRecordTypeBuilder(). SetRecordField("Field2", NewRecordTypeBuilder().
SetField("Field3", TypeString). SetField("Field3", TypeString).
SetField("Field4", List(TypeInteger)). SetField("Field4", ListOf(TypeInteger)).
SetRecordField("Field5", NewRecordTypeBuilder(). SetRecordField("Field5", NewRecordTypeBuilder().
SetField("Field6", TypeString). SetField("Field6", TypeString).
SetField("Field7", TypeBytes), SetField("Field7", TypeBytes),

View File

@ -19,15 +19,15 @@ func TestToParquetLevels(t *testing.T) {
name: "nested type", name: "nested type",
args: args{ args: args{
NewRecordTypeBuilder(). NewRecordTypeBuilder().
SetLongField("ID"). SetField("ID", TypeLong).
SetLongField("CreatedAt"). SetField("CreatedAt", TypeLong).
SetRecordField("Person", NewRecordTypeBuilder(). SetRecordField("Person", NewRecordTypeBuilder().
SetStringField("zName"). SetField("zName", TypeString).
SetListField("emails", TypeString)). SetField("emails", ListOf(TypeString))).
SetStringField("Company"). SetField("Company", TypeString).
SetRecordField("Address", NewRecordTypeBuilder(). SetRecordField("Address", NewRecordTypeBuilder().
SetStringField("Street"). SetField("Street", TypeString).
SetStringField("City")).Build(), SetField("City", TypeString)).Build(),
}, },
want: &ParquetLevels{ want: &ParquetLevels{
startColumnIndex: 0, startColumnIndex: 0,