Skip to content

Commit

Permalink
pipeline.jl: convert code example to doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
suvayu committed Oct 22, 2024
1 parent 529d0a9 commit 8a65125
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/pipeline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,27 @@ by first creating a `DataFrame`. `args...` are passed on to the
connection `con` as the table `name`. This function can be used with
a `do`-block like this:
julia> as_table(con, "mytbl", (;col=collect(1:5))) do con, name
DD.query(con, "SELECT col, col+2 as 'shift_2' FROM '\$name'")
end |> DataFrame
5×2 DataFrame
Row │ col shift_2
│ Int64? Int64?
─────┼─────────────────
1 │ 1 3
2 │ 2 4
3 │ 3 5
4 │ 4 6
5 │ 5 7
```jldoctest
using DuckDB: DBInterface, DB
con = DBInterface.connect(DB)
as_table(con, "mytbl", (;col=collect(1:5))) do con, name
DD.query(con, "SELECT col, col+2 as 'shift_2' FROM '\$name'")
end |> DataFrame
# output
5×2 DataFrame
Row │ col shift_2
│ Int64? Int64?
─────┼─────────────────
1 │ 1 3
2 │ 2 4
3 │ 3 5
4 │ 4 6
5 │ 5 7
```
"""
function as_table(op::Function, con::DB, name::String, args...)
Expand Down

0 comments on commit 8a65125

Please sign in to comment.