Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 7581128

Browse files
author
kuba--
committed
Trying to fix TestTime_DayOfWeek
Signed-off-by: kuba-- <kuba@sourced.tech>
1 parent e1f4e4a commit 7581128

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

engine_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ var queries = []struct {
113113
"SELECT i FROM mytable WHERE i NOT BETWEEN 1 AND 2",
114114
[]sql.Row{{int64(3)}},
115115
},
116+
{
117+
"SELECT substring(mytable.s, 1, 5) as s FROM mytable INNER JOIN othertable ON (substring(mytable.s, 1, 5) = SUBSTRING(othertable.s2, 1, 5)) GROUP BY 1",
118+
[]sql.Row{
119+
{"third"},
120+
{"secon"},
121+
{"first"},
122+
},
123+
},
116124
{
117125
"SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2",
118126
[]sql.Row{

sql/analyzer/resolve_columns.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ func qualifyColumns(ctx *sql.Context, a *Analyzer, n sql.Node) (sql.Node, error)
104104
col.Name(),
105105
)
106106
default:
107+
if _, ok := n.(*plan.GroupBy); ok {
108+
return expression.NewUnresolvedColumn(col.Name()), nil
109+
}
107110
return nil, ErrAmbiguousColumnName.New(col.Name(), strings.Join(tables, ", "))
108111
}
109112
} else {

sql/expression/function/time_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func TestTime_DayOfWeek(t *testing.T) {
243243
{"null date", sql.NewRow(nil), nil, false},
244244
{"invalid type", sql.NewRow([]byte{0, 1, 2}), nil, false},
245245
{"date as string", sql.NewRow(stringDate), int32(3), false},
246-
{"date as time", sql.NewRow(time.Now()), int32(time.Now().UTC().Weekday()+1) % 7, false},
246+
{"date as time", sql.NewRow(time.Now()), int32(time.Now().UTC().Weekday() + 1), false},
247247
{"date as unix timestamp", sql.NewRow(int64(tsDate)), int32(1), false},
248248
}
249249

0 commit comments

Comments
 (0)