Latest version 0.2.0
of SQLdf uses as default RDB engine SQLite.jl instead accessing R/sqldf
via RCall
. This latest version and its default has the following new features:
- More responsive access to SQLite
- Ability to query any Julia type implementing
Tables.jl
interface - Ability to mix in the same query Julia types implementing
Tables.jl
interface - @sqldf macro
Regardless the types used in the query the result will always be a DataFrame. Below there is an example joining a DataFrame
and a TimeArray
with duplicated column names.
Note: In this version it is still possible to access R/sqldf
by using the command setRDB("R")
, to set sqldf
’s default back to SQLite.jl
we need to use setRDB("SQLite")
.
using SQLdf, TimeSeries
DF = DataFrame(a=1:14, b=14:-1:1, c = split("Julia is great",""))
TA = TimeArray(Date(2021, 1, 1):Day(1):Date(2021, 1, 14), 1:14)
julia> @sqldf "select * from TA join DF where TA.A = DF.a"
14×5 DataFrame
Row │ timestamp A a:1 b c
│ Date Int64 Int64 Int64 String
─────┼─────────────────────────────────────────
1 │ 2021-01-01 1 1 14 J
2 │ 2021-01-02 2 2 13 u
3 │ 2021-01-03 3 3 12 l
4 │ 2021-01-04 4 4 11 i
5 │ 2021-01-05 5 5 10 a
6 │ 2021-01-06 6 6 9
7 │ 2021-01-07 7 7 8 i
8 │ 2021-01-08 8 8 7 s
9 │ 2021-01-09 9 9 6
10 │ 2021-01-10 10 10 5 g
11 │ 2021-01-11 11 11 4 r
12 │ 2021-01-12 12 12 3 e
13 │ 2021-01-13 13 13 2 a
14 │ 2021-01-14 14 14 1 t