Skip to content

Commit a774abc

Browse files
committed
Merge master into branch
2 parents 3659d26 + 195470c commit a774abc

14 files changed

+75
-157
lines changed

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ os:
55
julia:
66
- 0.7
77
- 1.0
8+
- 1.1
89
- nightly
910
notifications:
1011
email: false
1112
branches:
1213
only:
1314
- master
1415
- /release-.*/
15-
- /v(\d+)\.(\d+)\.(\d+)/
16+
- /v(\d+)\.(\d+)\.(\d+)/
1617
matrix:
1718
allow_failures:
1819
- julia: nightly
@@ -22,7 +23,7 @@ after_success:
2223
jobs:
2324
include:
2425
- stage: "Documentation"
25-
julia: 1.0
26+
julia: 1.1
2627
os: linux
2728
script:
2829
- julia --project=docs/ -e 'using Pkg; Pkg.instantiate(); Pkg.develop(PackageSpec(path=pwd()))'

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Query.jl v0.11.0 Release Notes
2-
* Add @select, @rename and @mutate standalone macros
2+
* Add @unique, @select, @rename and @mutate standalone macros
33
* Fix all doctest errors
44
* Various bugfixes
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ any array,
2727

2828
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.
2929

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.
3131

3232
## Alternatives
3333
[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!*

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ TableTraits 0.3.1
33
IterableTables 0.8.2
44
DataValues 0.4.4
55
MacroTools 0.4.4
6-
QueryOperators 0.5.1
6+
QueryOperators 0.6.0

appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
environment:
22
matrix:
33
- julia_version: 0.7
4-
- julia_version: 1
4+
- julia_version: 1.0
5+
- julia_version: 1.1
56
- julia_version: nightly
67

78
platform:

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ Query = "1a8c2f83-1ff3-5112-b086-8aa67b057ba1"
66
TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9"
77

88
[compat]
9-
Documenter = "~0.20"
9+
Documenter = "~0.21"

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ using Documenter, Query
33
makedocs(
44
modules = [Query],
55
sitename = "Query.jl",
6+
analytics="UA-132838790-1",
67
pages = [
78
"Introduction" => "index.md",
89
"Getting Started" => "gettingstarted.md",
910
"Standalone Query Commands" => "standalonequerycommands.md",
10-
"LINQ Style Query Commands" => "linqquerycommands.md",
11+
"LINQ Style Query Commands" => "linqquerycommands.md",
1112
"Data Sources" => "sources.md",
1213
"Data Sinks" => "sinks.md",
1314
"Experimental Features" => "experimental.md",

docs/src/experimental.md

Lines changed: 20 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -6,136 +6,9 @@ deal with significant changes to these features in future versions of
66
Query.jl. At the same time any feedback on these features would be
77
especially welcome.
88

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
1410

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.
13912

14013
## The `_` and `__` syntax
14114

@@ -157,3 +30,21 @@ df_children = DataFrame(Name=["Bill", "Joe", "Mary"], Parent=["John", "John", "S
15730

15831
df_parents |> @join(df_children, _.Name, _.Parent, {Parent=_.Name, Child=__.Name}) |> DataFrame
15932
```
33+
34+
## Key selector in the `@unique` standalone command
35+
36+
As an experimental feature, one can specify a key selector for the `@unique` command. In that case uniqueness is tested based on that key.
37+
38+
```jldoctest
39+
using Query
40+
41+
source = [1,-1,2,2,3]
42+
43+
q = source |> @unique(abs(_)) |> collect
44+
45+
println(q)
46+
47+
# output
48+
49+
[1, 2, 3]
50+
```

docs/src/gettingstarted.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Query.jl supports two different front-end syntax options: 1) standalone query op
44

55
## Standalone query operators
66

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:
88

99
```jldoctest
1010
using Query, DataFrames
@@ -37,7 +37,7 @@ q = @from <range variable> in <source> begin
3737
end
3838
```
3939

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:
4141

4242
```jldoctest
4343
using Query, DataFrames

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
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)).
66

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/).
88

99
## Installation
1010

0 commit comments

Comments
 (0)