(t *testing.T)
| 475 | } |
| 476 | |
| 477 | func TestAST_RewriteWithFunctionRef(t *testing.T) { |
| 478 | sqlVariations := []struct { |
| 479 | title string |
| 480 | sql string |
| 481 | replace []*TableRef |
| 482 | expectedSql string |
| 483 | }{ |
| 484 | { |
| 485 | "with single path and literal prop", |
| 486 | `select * from AdBids`, |
| 487 | []*TableRef{ |
| 488 | { |
| 489 | Function: "read_csv", |
| 490 | Paths: []string{"/path/to/AdBids.csv"}, |
| 491 | Properties: map[string]any{ |
| 492 | "delim": "|", |
| 493 | }, |
| 494 | }, |
| 495 | }, |
| 496 | `SELECT * FROM read_csv(main.list_value('/path/to/AdBids.csv'), (delim = '|'))`, |
| 497 | }, |
| 498 | { |
| 499 | "with single path and float prop", |
| 500 | `select * from AdBids`, |
| 501 | []*TableRef{ |
| 502 | { |
| 503 | Function: "read_csv", |
| 504 | Paths: []string{"/path/to/AdBids.csv"}, |
| 505 | Properties: map[string]any{ |
| 506 | "sample_size": float64(-1), |
| 507 | }, |
| 508 | }, |
| 509 | }, |
| 510 | `SELECT * FROM read_csv(main.list_value('/path/to/AdBids.csv'), (sample_size = -1))`, |
| 511 | }, |
| 512 | { |
| 513 | "with multiple paths with map prop", |
| 514 | `select * from AdBids`, |
| 515 | []*TableRef{ |
| 516 | { |
| 517 | Function: "read_csv", |
| 518 | Paths: []string{"/path/to/AdBids1.csv", "/path/to/AdBids2.csv"}, |
| 519 | Properties: map[string]any{ |
| 520 | "columns": map[string]any{ |
| 521 | "A": "Date", |
| 522 | }, |
| 523 | }, |
| 524 | }, |
| 525 | }, |
| 526 | `SELECT * FROM read_csv(main.list_value('/path/to/AdBids1.csv', '/path/to/AdBids2.csv'), ("columns" = main.struct_pack(A := 'Date')))`, |
| 527 | }, |
| 528 | { |
| 529 | "with deep map prop", |
| 530 | `select * from AdBids`, |
| 531 | []*TableRef{ |
| 532 | { |
| 533 | Function: "read_csv", |
| 534 | Paths: []string{"/path/to/AdBids.csv"}, |
nothing calls this directly
no test coverage detected