Documentation
¶
Index ¶
- Variables
- func Convert(toType DataType, v interface{}) (interface{}, error)
- func IsConvertible(from DataType, to DataType) bool
- func ParseTimestamp(rawTimestamp interface{}) (time.Time, error)
- func ReformatNumberValue(v interface{}) interface{}
- func ReformatTimeValue(value interface{}) interface{}
- func ReformatValue(v interface{}) interface{}
- func StringFromType(dataType DataType) (string, error)
- func StringToFloat(v interface{}) (interface{}, error)
- func StringToInt(v interface{}) (interface{}, error)
- func StringWithCommasToFloat(v interface{}) (interface{}, error)
- type ConvertFunc
- type DataType
- 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 ParseTimestamp ¶
func ReformatNumberValue ¶
func ReformatNumberValue(v interface{}) interface{}
ReformatNumberValue process json.Number types into int64 or float64 note: json.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 ¶
func ReformatTimeValue(value interface{}) interface{}
ReformatTimeValue processes string with ISO DateTime or Golang layout into time.Time
func ReformatValue ¶
func ReformatValue(v interface{}) interface{}
ReformatNumberValue process json.Number types into int64 or float64 processes string with ISO DateTime or Golang layout into time.Time note: json.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 ¶
func StringToFloat(v interface{}) (interface{}, error)
StringToFloat return float64 value from string or error if unconvertable
func StringToInt ¶
func StringToInt(v interface{}) (interface{}, error)
StringToInt returns int representation of input string or error if unconvertable
func StringWithCommasToFloat ¶
func StringWithCommasToFloat(v interface{}) (interface{}, error)
StringWithCommasToFloat return float64 value from string (1,200.50)
Types ¶
type ConvertFunc ¶
type ConvertFunc func(v interface{}) (interface{}, error)
ConvertFunc is a function for a certain DataType conversion
type DataType ¶
type DataType int
DataType is a type representation of common data types
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