Documentation ¶
Index ¶
- Variables
- func Convert(toType DataType, v any) (any, error)
- func IsConvertible(from DataType, to DataType) bool
- func ObjectValuesToString(header []string, valueArgs []any) string
- func ParseTimestamp(rawTimestamp any) (time.Time, error)
- func ReformatNumberValue(v any) any
- func ReformatTimeValue(value any) any
- func ReformatValue(v any) any
- func StringFromType(dataType DataType) (string, error)
- func StringToFloat(v any) (any, error)
- func StringToInt(v any) (any, error)
- func StringWithCommasToFloat(v any) (any, error)
- type AbstractMarshaller
- type CSVMarshaller
- func (cm *CSVMarshaller) Compression() FileCompression
- func (cm *CSVMarshaller) Flush() error
- func (cm *CSVMarshaller) Format() FileFormat
- func (cm *CSVMarshaller) Init(writer io.Writer, header []string) error
- func (cm *CSVMarshaller) Marshal(object ...Object) error
- func (cm *CSVMarshaller) NeedHeader() bool
- type ConvertFunc
- type DataType
- type ErrorPayload
- type FileCompression
- type FileFormat
- type JSONMarshaller
- func (jm *JSONMarshaller) Compression() FileCompression
- func (jm *JSONMarshaller) Flush() error
- func (jm *JSONMarshaller) Format() FileFormat
- func (jm *JSONMarshaller) Init(writer io.Writer, _ []string) error
- func (jm *JSONMarshaller) Marshal(object ...Object) error
- func (jm *JSONMarshaller) NeedHeader() bool
- type Marshaller
- type Object
- type SQLColumn
- type SQLTypes
Constants ¶
This section is empty.
Variables ¶
var ( DefaultTypes = map[string]DataType{ timestamp.Key: TIMESTAMP, "eventn_ctx_utc_time": TIMESTAMP, "eventn_ctx_interval_start": TIMESTAMP, "eventn_ctx_interval_end": TIMESTAMP, "utc_time": TIMESTAMP, "interval_start": TIMESTAMP, "interval_end": TIMESTAMP, } )
Typecast tree
STRING(4) / \
FLOAT64(3) TIMESTAMP(5)
| INT64(2) | BOOL(1)
Functions ¶
func IsConvertible ¶
IsConvertible returns false if there isn't any rule for converting from DataType into to DataType
func ObjectValuesToString ¶
func ReformatNumberValue ¶
ReformatNumberValue process json.Number types into int64 or float64 note: jsoniter.Unmarshal returns json.Number type that can be int or float
we have to check does json number have dot in string representation
if have -> return float64 otherwise int64
func ReformatTimeValue ¶
ReformatTimeValue processes string with ISO DateTime or Golang layout into time.Time
func ReformatValue ¶
ReformatNumberValue process json.Number types into int64 or float64 processes string with ISO DateTime or Golang layout into time.Time note: jsoniter.Unmarshal returns json.Number type that can be int or float
we have to check does json number have dot in string representation
if have -> return float64 otherwise int64
func StringFromType ¶
StringFromType returns string representation of DataType or error if mapping doesn't exist
func StringToFloat ¶
StringToFloat return float64 value from string or error if unconvertable
func StringToInt ¶
StringToInt returns int representation of input string or error if unconvertable
func StringWithCommasToFloat ¶
StringWithCommasToFloat return float64 value from string (1,200.50)
Types ¶
type AbstractMarshaller ¶
type AbstractMarshaller struct {
// contains filtered or unexported fields
}
func (*AbstractMarshaller) Equal ¶
func (am *AbstractMarshaller) Equal(m Marshaller) bool
type CSVMarshaller ¶
type CSVMarshaller struct { AbstractMarshaller // contains filtered or unexported fields }
func (*CSVMarshaller) Compression ¶
func (cm *CSVMarshaller) Compression() FileCompression
func (*CSVMarshaller) Flush ¶
func (cm *CSVMarshaller) Flush() error
func (*CSVMarshaller) Format ¶
func (cm *CSVMarshaller) Format() FileFormat
func (*CSVMarshaller) Marshal ¶
func (cm *CSVMarshaller) Marshal(object ...Object) error
Marshal marshals input object as csv values string with delimiter
func (*CSVMarshaller) NeedHeader ¶
func (cm *CSVMarshaller) NeedHeader() bool
type ConvertFunc ¶
ConvertFunc is a function for a certain DataType conversion
type DataType ¶
type DataType int
DataType is a type representation of common data types
const ( //UNKNOWN type for error cases UNKNOWN DataType = iota //BOOL type for boolean values BOOL //INT64 type for int values INT64 //FLOAT64 type for float values FLOAT64 //STRING type for string values STRING //TIMESTAMP type for string values that match timestamp pattern TIMESTAMP //JSON type for json values JSON )
func DataTypePtr ¶
func GetCommonAncestorType ¶
GetCommonAncestorType returns lowest common ancestor type
func TypeFromString ¶
TypeFromString returns DataType from input string or error if mapping doesn't exist
func TypeFromValue ¶
TypeFromValue return DataType from v type
type ErrorPayload ¶
type ErrorPayload struct { Dataset string Bucket string Project string Database string Cluster string Schema string Table string Partition string PrimaryKeys []string Statement string Values []any ValuesMapString string TotalObjects int }
func (*ErrorPayload) String ¶
func (ep *ErrorPayload) String() string
type FileCompression ¶
type FileCompression string
const ( FileCompressionGZIP FileCompression = "gzip" FileCompressionNONE FileCompression = "none" FileCompressionUNKNOWN FileCompression = "" )
type FileFormat ¶
type FileFormat string
const ( FileFormatCSV FileFormat = "csv" FileFormatNDJSON FileFormat = "ndjson" FileFormatNDJSONFLAT FileFormat = "ndjson_flat" )
type JSONMarshaller ¶
type JSONMarshaller struct { AbstractMarshaller // contains filtered or unexported fields }
func (*JSONMarshaller) Compression ¶
func (jm *JSONMarshaller) Compression() FileCompression
func (*JSONMarshaller) Flush ¶
func (jm *JSONMarshaller) Flush() error
func (*JSONMarshaller) Format ¶
func (jm *JSONMarshaller) Format() FileFormat
func (*JSONMarshaller) Marshal ¶
func (jm *JSONMarshaller) Marshal(object ...Object) error
Marshal object as json
func (*JSONMarshaller) NeedHeader ¶
func (jm *JSONMarshaller) NeedHeader() bool
type Marshaller ¶
type Marshaller interface { Init(writer io.Writer, header []string) error Marshal(...Object) error Flush() error NeedHeader() bool Format() FileFormat Compression() FileCompression Equal(Marshaller) bool }
func NewMarshaller ¶
func NewMarshaller(format FileFormat, compression FileCompression) (Marshaller, error)