Example_extractWindowFunctions demonstrates extracting window functions.
()
| 677 | |
| 678 | // Example_extractWindowFunctions demonstrates extracting window functions. |
| 679 | func Example_extractWindowFunctions() { |
| 680 | sql := `SELECT |
| 681 | name, |
| 682 | salary, |
| 683 | ROW_NUMBER() OVER (PARTITION BY department ORDER BY salary DESC) as rank, |
| 684 | AVG(salary) OVER (PARTITION BY department) as dept_avg |
| 685 | FROM employees` |
| 686 | |
| 687 | ast, err := gosqlx.Parse(sql) |
| 688 | if err != nil { |
| 689 | log.Fatal(err) |
| 690 | } |
| 691 | |
| 692 | functions := gosqlx.ExtractFunctions(ast) |
| 693 | fmt.Printf("Window functions found: %d\n", len(functions)) |
| 694 | // Output: Window functions found: 2 |
| 695 | } |
nothing calls this directly
no test coverage detected