You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ any array,
27
27
28
28
The package currently provides working implementations for in-memory data sources, but will eventually be able to translate queries into e.g. SQL. There is a prototype implementation of such a "query provider" for [SQLite](https://github.com/JuliaDB/SQLite.jl) in the package, but it is experimental at this point and only works for a *very* small subset of queries.
29
29
30
-
Query is heavily inspired by [LINQ](https://msdn.microsoft.com/en-us/library/bb397926.aspx), in fact right now the package is largely an implementation of the [LINQ](https://msdn.microsoft.com/en-us/library/bb397926.aspx) part of the [C# specification](https://msdn.microsoft.com/en-us/library/ms228593.aspx). Future versions of Query will most likely add features that are not found in the original [LINQ](https://msdn.microsoft.com/en-us/library/bb397926.aspx) design.
30
+
Query is heavily inspired by [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/index), in fact right now the package is largely an implementation of the [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/indexq) part of the [C# specification](https://msdn.microsoft.com/en-us/library/ms228593.aspx). Future versions of Query will most likely add features that are not found in the original [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/index) design.
31
31
32
32
## Alternatives
33
33
[Query.jl](https://github.com/queryverse/Query.jl) is not the only julia initiative for querying data, there are many other packages that have similar goals. Take a look at [DataFramesMeta.jl](https://github.com/JuliaStats/DataFramesMeta.jl), [StructuredQueries.jl](https://github.com/davidagold/StructuredQueries.jl), [LazyQuery.jl](https://github.com/bramtayl/LazyQuery.jl) and [SplitApplyCombine.jl](https://github.com/JuliaData/SplitApplyCombine.jl). *If I missed other initiatives, please let me know and I'll add them to this list!*
@@ -6,136 +6,9 @@ deal with significant changes to these features in future versions of
6
6
Query.jl. At the same time any feedback on these features would be
7
7
especially welcome.
8
8
9
-
The `@map`, `@filter`, `@groupby`, `@orderby` (and various variants),
10
-
`@groupjoin`, `@join`, `@mapmany`, `@take` and `@drop` commands can be used in standalone
11
-
versions. Those standalone versions are especially convenient in
12
-
combination with the pipe syntax in julia. Here is an example that
13
-
demonstrates their use:
9
+
## Source as the first argument to standalone query commands
14
10
15
-
```julia
16
-
using Query, DataFrames, Statistics
17
-
18
-
df =DataFrame(a=[1,1,2,3], b=[4,5,6,8])
19
-
20
-
df2 = df |>
21
-
@groupby(_.a) |>
22
-
@map({a=key(_), b=mean(_.b)}) |>
23
-
@filter(_.b >5) |>
24
-
@orderby_descending(_.b) |>
25
-
DataFrame
26
-
```
27
-
28
-
This example makes use of three experimental features: 1) the standalone
29
-
query commands, 2) the `.` syntax and 3) the `_` anonymous function syntax.
30
-
31
-
## Standalone query operators
32
-
33
-
All standalone query commands can either take a source as their first
34
-
argument, or one can pipe the source into the command, as in the above
35
-
example. For example, one can either write
36
-
37
-
```julia
38
-
df = df |>@groupby(_.a)
39
-
```
40
-
or
41
-
```julia
42
-
df =@groupby(df, _.a)
43
-
```
44
-
both forms are equivalent.
45
-
46
-
The remaining arguments of each query demand are command specific.
47
-
48
-
The following discussion will present each command in the version that
49
-
accepts a source as the first argument.
50
-
51
-
### The `@map` command
52
-
53
-
The `@map` command has the form `@map(source, element_selector)`.
54
-
`source` can be any source that can be queried. `element_selector` must
55
-
be an anonymous function that accepts one element of the element type of
56
-
the source and applies some transformation to this single element.
57
-
58
-
### The `@filter` command
59
-
60
-
The `@filter` command has the form `@filter(source, filter_condition)`.
61
-
`source` can be any source that can be queried. `filter_condition` must
62
-
be an anonymous function that accepts one element of the element type of
63
-
the source and returns `true` if that element should be retained, and
64
-
`false` if that element should be filtered out.
65
-
66
-
### The `@groupby` command
67
-
68
-
There are two versions of the `@groupby` command. The simple version has
69
-
the form `@groupby(source, key_selector)`. `source` can be any source
70
-
that can be queried. `key_selector` must be an anonymous function that
71
-
returns a value for each element of `source` by which the source elements
72
-
should be grouped.
73
-
74
-
The second variant has the form `@groupby(source, key_selector, element_selector)`.
75
-
The definition of `source` and `key_selector` is the same as in the simple
76
-
variant. `element_selector` must be an anonymous function that is applied
77
-
to each element of the `source` before that element is placed into a group,
78
-
i.e. this is a projection function.
79
-
80
-
The return value of `@groupby` is an iterable of groups. Each group is itself a
81
-
collection of data rows, and has a `key` field that is equal to the value the
82
-
rows were grouped by. Often the next step in the pipeline will be to use `@map`
83
-
with a function that acts on each group, summarizing it in a new data row.
84
-
85
-
### The `@orderby`, `@orderby_descending`, `@thenby` and `@thenby_descending` command
86
-
87
-
There are four commands that are used to sort data. Any sorting has to
88
-
start with either a `@orderby` or `@orderby_descending` command. `@thenby`
89
-
and `@thenby_descending` commands can only directly follow a previous sorting
90
-
command. They specify how ties in the previous sorting condition are to be
91
-
resolved.
92
-
93
-
The general sorting command form is `@orderby(source, key_selector)`.
94
-
`source` can be any source than can be queried. `key_selector` must be an
95
-
anonymous function that returns a value for each element of `source`. The
96
-
elements of the source are then sorted is ascending order by the value
97
-
returned from the `key_selector` function. The `@orderby_descending`
98
-
command works in the same way, but sorts things in descending order. The
99
-
`@thenby` and `@thenby_descending` command only accept the return value
100
-
of any of the four sorting commands as their `source`, otherwise they have
101
-
the same syntax as the `@orderby` and `@orderby_descending` commands.
102
-
103
-
### The `@groupjoin` command
104
-
105
-
The `@groupjoin` command has the form `@groupjoin(outer, inner, outer_selector, inner_selector, result_selector)`.
106
-
`outer` and `inner` can be any source that can be queried. `outer_selector`
107
-
and `inner_selector` must be an anonymous function that extracts the value
108
-
from the outer and inner source respectively on which the join should
109
-
be run. The `result_selector` must be an anonymous function that takes two
110
-
arguments, first the element from the `outer` source, and second an array
111
-
of those elements from the second source that are grouped together.
112
-
113
-
### The `@join` command
114
-
115
-
The `@join` command has the form `@join(outer, inner, outer_selector, inner_selector, result_selector)`.
116
-
`outer` and `inner` can be any source that can be queried. `outer_selector`
117
-
and `inner_selector` must be an anonymous function that extracts the value
118
-
from the outer and inner source respectively on which the join should
119
-
be run. The `result_selector` must be an anonymous function that takes two
120
-
arguments. It will be called for each element in the result set, and the
121
-
first argument will hold the element from the outer source and the second
122
-
argument will hold the element from the inner source.
123
-
124
-
### The `@mapmany` command
125
-
126
-
The `@mapmany` command has the form `@mapmany(source, collection_selector, result_selector)`.
127
-
`source` can be any source that can be queried. `collection_selector` must
128
-
be an anonymous function that takes one argument and returns a collection.
129
-
`result_selector` must be an anonymous function that takes two arguments.
130
-
It will be applied to each element of the intermediate collection.
131
-
132
-
### The `@take` command
133
-
134
-
The `@take` command has the form `@take(source, n)`. `source` can be any source that can be queried. `n` must be an integer, and it specifies how many elements from the beginning of the source should be kept.
135
-
136
-
### The `@drop` command
137
-
138
-
The `@drop` command has the form `@drop(source, n)`. `source` can be any source that can be queried. `n` must be an integer, and it specifies how many elements from the beginning of the source should be dropped from the results.
11
+
Some standalone query commands accept the source argument as the first argument, in addition to accepting it via the pipe operator. For example, `source |> @map(_)` and @map(source, _)` are equivalent. These source-as-the-first-argument versions of the standalone query operators are considered experimental and might disappear in future releases.
Copy file name to clipboardExpand all lines: docs/src/gettingstarted.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ Query.jl supports two different front-end syntax options: 1) standalone query op
4
4
5
5
## Standalone query operators
6
6
7
-
The standalone query operators are typically combined into more complicated queries via the pipe operator. The example from the previous section can also be written like this, using the `@filter`and `@map` standalone query operators:
7
+
The standalone query operators are typically combined into more complicated queries via the pipe operator. Probably the most simple example is a query that filters a DataFrame and returns a subset of its columns:
8
8
9
9
```jldoctest
10
10
using Query, DataFrames
@@ -37,7 +37,7 @@ q = @from <range variable> in <source> begin
37
37
end
38
38
```
39
39
40
-
Multiple `<query statements>` are separated by line breaks. Probably the most simple example is a query that filters a `DataFrame` and returns a subset of its columns:
40
+
Multiple `<query statements>` are separated by line breaks. The example from the previous section can also be written like this using LINQ style queryies:
Copy file name to clipboardExpand all lines: docs/src/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
Query is a package for querying julia data sources. It can filter, project, join, sort and group data from any iterable data source, including all the sources that support the [TableTraits.jl](https://github.com/queryverse/TableTraits.jl) interface (this includes everything listed in [IterableTables.jl](https://github.com/queryverse/IterableTables.jl)).
6
6
7
-
Query is heavily inspired by [LINQ](https://msdn.microsoft.com/en-us/library/bb397926.aspx) and [dplyr](https://dplyr.tidyverse.org/).
7
+
Query is heavily inspired by [LINQ](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/linq/index) and [dplyr](https://dplyr.tidyverse.org/).
0 commit comments