Calculated field
USERNAME()
Sample data
| label | quantity | amount | flag |
|---|---|---|---|
| cedar cedar | 65 | 12.8 | True |
| ORCHID-west | 66 | -7.6 | False |
| maple-east | 67 | 0 | null |
| willow north | 68 | 25.3 | True |
| birch-birch | 69 | 4.9 | False |
| pine/south | 70 | -1.2 | null |
| ash | 71 | 9 | True |
| null | null | null | null |
The same calculation as SQL
SELECT 'linh@example.test' AS result FROM input
Runs the example above.
SELECT 'linh@example.test' AS result FROM input
Written for this dialect; not run here.
SELECT 'linh@example.test' AS result FROM input
Written for this dialect; not run here.
Result
| result |
|---|
| linh@example.test |
| linh@example.test |
| linh@example.test |
| linh@example.test |
| linh@example.test |
| linh@example.test |
| linh@example.test |
| linh@example.test |
Same rows from the calculation and from the SQL in DuckDB.
Where a naive translation goes wrong
- SQL must receive the application user context; database session identity is a different principal.
Naive SQL
SELECT 'warehouse_service' AS result FROM input
result warehouse_service warehouse_service warehouse_service warehouse_service warehouse_service warehouse_service warehouse_service warehouse_service Matches the calculation
SELECT 'linh@example.test' AS result FROM input
result linh@example.test linh@example.test linh@example.test linh@example.test linh@example.test linh@example.test linh@example.test linh@example.test
Signature
USERNAME()