From bb2c805cac3ca952086476a8e8b86b0d0778aff4 Mon Sep 17 00:00:00 2001 From: pokeeffe-molecula <85502298+pokeeffe-molecula@users.noreply.github.com> Date: Wed, 14 Dec 2022 17:53:17 -0600 Subject: [PATCH] handling missing epoch constraint correctly (#2366) (cherry picked from commit 843312dfc9f1307376ce53d13b8479bc775c17a2) --- sql3/planner/compilecreatetable.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sql3/planner/compilecreatetable.go b/sql3/planner/compilecreatetable.go index 3a5eb5f34..1d34aadae 100644 --- a/sql3/planner/compilecreatetable.go +++ b/sql3/planner/compilecreatetable.go @@ -170,12 +170,14 @@ func (p *ExecutionPlanner) compileColumn(col *parser.ColumnDefinition) (*createT unit := c.Expr.(*parser.StringLit) timeUnit = unit.Value - epochString := c.EpochExpr.(*parser.StringLit) - tm, err := time.ParseInLocation(time.RFC3339, epochString.Value, time.UTC) - if err != nil { - return nil, sql3.NewErrInvalidTimeEpoch(c.EpochExpr.Pos().Line, c.EpochExpr.Pos().Line, epochString.Value) + if c.EpochExpr != nil { + epochString := c.EpochExpr.(*parser.StringLit) + tm, err := time.ParseInLocation(time.RFC3339, epochString.Value, time.UTC) + if err != nil { + return nil, sql3.NewErrInvalidTimeEpoch(c.EpochExpr.Pos().Line, c.EpochExpr.Pos().Line, epochString.Value) + } + epoch = tm } - epoch = tm case *parser.TimeQuantumConstraint: unit := c.Expr.(*parser.StringLit)