-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support int64 data types #2261
Support int64 data types #2261
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,8 +17,10 @@ type DataType string | |
const ( | ||
// Unknown primitive data type. | ||
Unknown = DataType("") | ||
// Number means the data type is an int or float. | ||
Number = DataType("number") | ||
// Float means the data type is a float | ||
Float = DataType("float") | ||
// Integer means the data type is a integer | ||
Integer = DataType("integer") | ||
// Boolean means the data type is a boolean. | ||
Boolean = DataType("boolean") | ||
// String means the data type is a string of text. | ||
|
@@ -33,9 +35,9 @@ const ( | |
func InspectDataType(v interface{}) DataType { | ||
switch v.(type) { | ||
case float64: | ||
return Number | ||
case int: | ||
return Number | ||
return Float | ||
case int64, int32, int: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is really necessary. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might just need |
||
return Integer | ||
case bool: | ||
return Boolean | ||
case string: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -976,6 +976,39 @@ func TestServer_StartRetentionPolicyEnforcement_ErrZeroInterval(t *testing.T) { | |
} | ||
} | ||
|
||
// Ensure the server can support writes of all data types. | ||
func TestServer_WriteAllDataTypes(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Must add test to |
||
c := test.NewDefaultMessagingClient() | ||
defer c.Close() | ||
s := OpenServer(c) | ||
defer s.Close() | ||
s.CreateDatabase("foo") | ||
s.CreateRetentionPolicy("foo", &influxdb.RetentionPolicy{Name: "raw", Duration: 1 * time.Hour}) | ||
s.SetDefaultRetentionPolicy("foo", "raw") | ||
|
||
// Write series with one point to the database. | ||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "series1", Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": float64(20)}}}) | ||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "series2", Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": int64(30)}}}) | ||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "series3", Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": "baz"}}}) | ||
s.MustWriteSeries("foo", "raw", []influxdb.Point{{Name: "series4", Timestamp: mustParseTime("2000-01-01T00:00:00Z"), Fields: map[string]interface{}{"value": true}}}) | ||
|
||
f := func(t *testing.T, database, query, expected string) { | ||
results := s.executeQuery(MustParseQuery(query), database, nil) | ||
if res := results.Results[0]; res.Err != nil { | ||
t.Errorf("unexpected error: %s", res.Err) | ||
} else if len(res.Series) != 1 { | ||
t.Errorf("unexpected row count: %d", len(res.Series)) | ||
} else if s := mustMarshalJSON(res); s != expected { | ||
t.Errorf("unexpected row(0): \nexp: %s\ngot: %s", expected, s) | ||
} | ||
} | ||
|
||
f(t, "foo", "SELECT * from series1", `{"series":[{"name":"series1","columns":["time","value"],"values":[["2000-01-01T00:00:00Z",20]]}]}`) | ||
f(t, "foo", "SELECT * from series2", `{"series":[{"name":"series2","columns":["time","value"],"values":[["2000-01-01T00:00:00Z",30]]}]}`) | ||
f(t, "foo", "SELECT * from series3", `{"series":[{"name":"series3","columns":["time","value"],"values":[["2000-01-01T00:00:00Z","baz"]]}]}`) | ||
f(t, "foo", "SELECT * from series4", `{"series":[{"name":"series4","columns":["time","value"],"values":[["2000-01-01T00:00:00Z",true]]}]}`) | ||
} | ||
|
||
func TestServer_EnforceRetentionPolices(t *testing.T) { | ||
c := test.NewDefaultMessagingClient() | ||
s := OpenServer(c) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems easiest to just cast it to an unsigned value, and just encode it as that.