| 379 | } |
| 380 | |
| 381 | func TestWindowFrameSQL(t *testing.T) { |
| 382 | // Test through SelectStatement with window spec that has frame |
| 383 | stmt := &SelectStatement{ |
| 384 | Columns: []Expression{&Identifier{Name: "x"}}, |
| 385 | From: []TableReference{{Name: "t"}}, |
| 386 | Windows: []WindowSpec{ |
| 387 | { |
| 388 | Name: "w1", |
| 389 | PartitionBy: []Expression{&Identifier{Name: "a"}}, |
| 390 | OrderBy: []OrderByExpression{{Expression: &Identifier{Name: "b"}, Ascending: true}}, |
| 391 | FrameClause: &WindowFrame{ |
| 392 | Type: "ROWS", |
| 393 | Start: WindowFrameBound{Type: "UNBOUNDED PRECEDING"}, |
| 394 | End: &WindowFrameBound{Type: "CURRENT ROW"}, |
| 395 | }, |
| 396 | }, |
| 397 | }, |
| 398 | } |
| 399 | sql := stmt.SQL() |
| 400 | if !strings.Contains(sql, "ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW") { |
| 401 | t.Errorf("got: %s", sql) |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | func TestFetchSQL(t *testing.T) { |
| 406 | fv := int64(10) |