mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 09:05:55 +00:00
set default epoch for timestamps in system tables
If we don't set an epoch, we get a cryptic message on the console. Note, this message isn't logged properly, it doesn't use the logger, it uses the `log` package. 2023/02/09 11:07:23 ERROR: converting timestamp options for end_time: checking overflow: custom epoch too far from Unix epoch: 0001-01-01 00:00:00 +0000 UTC Because this uses the log package, it doesn't go to the same place as other messages, making it a pain to debug. The underlying problem is that a timestamp can't just have a zero value for its epoch. So, we set a default epoch of 0 Unix Time. We should possibly revisit the question of whether the conversion in the top-level schema.go should handle an epoch which IsZero, but I'm not sure what "base" should be in that case. In practice, all existing usages except this one are specifying time.Unix(0, 0) already.
This commit is contained in:
parent
f4e1e63dd0
commit
10b60f5d51
1 changed files with 7 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ package planner
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
pilosa "github.com/featurebasedb/featurebase/v3"
|
||||
"github.com/featurebasedb/featurebase/v3/dax"
|
||||
|
|
@ -104,6 +105,7 @@ func indexInfoFromSystemTableB(st *systemTable) (*dax.Table, error) {
|
|||
|
||||
for _, f := range st.schema {
|
||||
var baseType dax.BaseType
|
||||
var epoch time.Time
|
||||
switch f.Type.(type) {
|
||||
case *parser.DataTypeInt:
|
||||
baseType = dax.BaseTypeInt
|
||||
|
|
@ -113,13 +115,15 @@ func indexInfoFromSystemTableB(st *systemTable) (*dax.Table, error) {
|
|||
baseType = dax.BaseTypeString
|
||||
case *parser.DataTypeTimestamp:
|
||||
baseType = dax.BaseTypeTimestamp
|
||||
epoch = time.Unix(0, 0)
|
||||
default:
|
||||
return nil, sql3.NewErrInternalf("unexpected system table field type '%T'", f.Type)
|
||||
}
|
||||
|
||||
_ = dax.FieldOptions{}
|
||||
fld := &dax.Field{
|
||||
Name: dax.FieldName(f.ColumnName),
|
||||
Type: baseType,
|
||||
Name: dax.FieldName(f.ColumnName),
|
||||
Type: baseType,
|
||||
Options: dax.FieldOptions{Epoch: epoch},
|
||||
}
|
||||
fields = append(fields, fld)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue