Skip to content

Commit

Permalink
Merge pull request #87 from getlantern/ox/issue86
Browse files Browse the repository at this point in the history
Added validation for all tables to have a resolution
  • Loading branch information
oxtoacart authored May 12, 2020
2 parents 08358da + c0b9bf8 commit 6529edb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions table.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func (db *DB) CreateTable(opts *TableOpts) error {
db.orderedTables = append(db.orderedTables, t)

if !t.Virtual {
if q.Resolution <= 0 {
return errors.New("Please specify a resolution for the table using PERIOD(...)")
}
var rsErr error
var offsetsBySource common.OffsetsBySource
if !t.db.opts.Passthrough {
Expand Down
8 changes: 8 additions & 0 deletions zenodb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ view_a:
return
}

// try to create a table that's missing a resolution
createErr := db.CreateTable(&TableOpts{
Name: "bad",
RetentionPeriod: 1 * time.Hour,
SQL: "SELECT * FROM inbound WHERE r = 'A' GROUP BY *",
})
assert.Error(t, createErr)

now := epoch
advance := func(d time.Duration) {
time.Sleep(250 * time.Millisecond)
Expand Down

0 comments on commit 6529edb

Please sign in to comment.