Skip to content

Instantly share code, notes, and snippets.

@kylebrandt
Last active October 28, 2021 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylebrandt/58969f0e2daf72f869cfb9cfc152c579 to your computer and use it in GitHub Desktop.
Save kylebrandt/58969f0e2daf72f869cfb9cfc152c579 to your computer and use it in GitHub Desktop.
DF Cue WIP
// Dataframe is a columnar table made up of fields
#Dataframe: {
Name: string,
Fields: [...#Field]
_fieldLen: int
// all fields must be the same length
// error message may be like "missMatchedLen._fieldLen: conflicting values 2 and 3" if an instance of
// Dataframe. This is because _fieldLen does not collacse to the same value
for f in Fields {
_fieldLen: len(f.values)
}
}
#Field: {
Name: string
Labels?: [string]: string
#FieldTypeRule
//FieldType: string
//values: #fieldValues
}
#FieldTypeRule: {
Type: string
values: [..._]
}
#fieldValues: [...int|null] | [...string|null]
myFrame: #Dataframe & {
Name: "TestFrame"
Fields: [
{
Name: "TestNumberField"
Labels: {"test": "test", "a": "b"}
Type: "int64"
values: [1,2,3,4]
},
{
Name: "TestNumberFieldWithNull"
Type: "nullableInt64"
values: [1,2,null,4]
},
{
Name: "TestSringField",
Type: "string"
values: ["a", "b", "c", "d"]
},
{
Name: "TestNumberFieldWithNull"
Type: "nullableString"
values: ["a", "b", null, "d"]
},
]
}
// myBadFrame: #Dataframe & {
// Name: "TestFrame2"
// Fields: [
// {
// Name: "TestNumberField",
// Labels: {"test": "test", "1": 1} // number bad
// values: [1,2,3]
// },
// {
// Name: "MixedValueTypesShouldFail",
// values: [1, "a"]
// }
// ]
// }
// missMatchedLen: #Dataframe & {
// Name: "TestFrame2"
// Fields: [
// {
// Name: "",
// values: [1,2,3]
// },
// {
// Name: "",
// values: [1, 2]
// }
// ]
// }
// FieldTypes
#FieldTypeInt8: #FieldTypeRule & {
Type: "int8"
values: [...int8]
}
#FieldTypeNullableInt8: #FieldTypeRule & {
Type: "nullableInt8"
values: [...int8|null]
}
#FieldTypeInt16: #FieldTypeRule & {
Type: "int16"
values: [...int16]
}
#FieldTypeNullableInt16: #FieldTypeRule & {
Type: "nullableInt16"
values: [...int16|null]
}
#FieldTypeInt32: #FieldTypeRule & {
Type: "int32"
values: [...int32]
}
#FieldTypeNullableInt32: #FieldTypeRule & {
Type: "nullableInt32"
values: [...int32|null]
}
#FieldTypeInt64: #FieldTypeRule & {
Type: "int64"
values: [...int64]
}
#FieldTypeNullableInt64: #FieldTypeRule & {
Type: "nullableInt64"
values: [...int64|null]
}
#FieldTypeUint8: #FieldTypeRule & {
Type: "uint8"
values: [...uint8]
}
#FieldTypeNullableUint8: #FieldTypeRule & {
Type: "nullableUint8"
values: [...uint8|null]
}
#FieldTypeUint16: #FieldTypeRule & {
Type: "uint16"
values: [...uint16]
}
#FieldTypeNullableUint16: #FieldTypeRule & {
Type: "nullableUint16"
values: [...uint16|null]
}
#FieldTypeUint32: #FieldTypeRule & {
Type: "uint32"
values: [...uint32]
}
#FieldTypeNullableUint32: #FieldTypeRule & {
Type: "nullableUint32"
values: [...uint32|null]
}
#FieldTypeUint64: #FieldTypeRule & {
Type: "uint64"
values: [...uint64]
}
#FieldTypeNullableUint64: #FieldTypeRule & {
Type: "nullableUint64"
values: [...uint64|null]
}
#FieldTypeFloat32: #FieldTypeRule & {
Type: "float32"
values: [...float32]
}
#FieldTypeNullableFloat32: #FieldTypeRule & {
Type: "nullableFloat32"
values: [...float32|null]
}
#FieldTypeFloat64: #FieldTypeRule & {
Type: "float64"
values: [...float64]
}
#FieldTypeNullableFloat64: #FieldTypeRule & {
Type: "nullablefloat64"
values: [...float64|null]
}
#FieldTypeString: #FieldTypeRule & {
Type: "string"
values: [...string]
}
#FieldTypeNullableString: #FieldTypeRule & {
Type: "nullableString"
values: [...string|null]
}
#FieldTypeBool: #FieldTypeRule & {
Type: "bool"
values: [...bool]
}
#FieldTypeNullableBool: #FieldTypeRule & {
Type: "nullableBool"
values: [...bool|null]
}
#FieldTypeTime: #FieldTypeRule & {
Type: "time"
values: [...time]
}
#FieldTypeNullableTime: #FieldTypeRule & {
Type: ""
values: [...time|null]
}
time: epochMS
epochMS: 0 | int64 // ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment