Skip to content

Commit 3396eec

Browse files
committed
Prevent panics
1 parent 455178f commit 3396eec

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

internal/compiler/output_columns.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ func (c *Compiler) sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, erro
608608
if err != nil {
609609
return nil, err
610610
}
611+
if qc == nil {
612+
return nil, fmt.Errorf("query catalog is empty")
613+
}
611614
table, cerr := qc.GetTable(fqn)
612615
if cerr != nil {
613616
// TODO: Update error location

internal/compiler/resolve.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ func (comp *Compiler) resolveCatalogRefs(qc *QueryCatalog, rvs []*ast.RangeVar,
6363
}
6464
table, err := c.GetTable(fqn)
6565
if err != nil {
66-
// If the table name doesn't exist, fisrt check if it's a CTE
66+
if qc == nil {
67+
continue
68+
}
69+
// If the table name doesn't exist, first check if it's a CTE
6770
if _, qcerr := qc.GetTable(fqn); qcerr != nil {
6871
return nil, err
6972
}

0 commit comments

Comments
 (0)