TypeQL: the polymorphic query language of TypeDB
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.typedb.com</id>
<url>https://repo.typedb.com/public/public-release/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.28.0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.28.0</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.28.0
Update maven artifacts snapshot Update maven artifacts snapshot
Update README.md
Update typedb-behaviour and implement missing steps
Finish updating license tests, dependencies, last missed headers
Replace licenses with MPL version 2.0
Update banner.png for the README file
Update the banner image in the README file.
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.typedb.com</id>
<url>https://repo.typedb.com/public/public-release/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.27.0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.27.0</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.27.0
Refactor TypeQL Java projection builder
We note a previous change in 2eef07d388391e073cc1631f5af2bbf15e844cc4 and extend it here to refactor the TypeQL Fetch projection query builder:
Usage rename, before:
cVar("x").map("name")
label("subquery").map(TypeQL.match(...).fetch(...))
Usage now:
cVar("x").fetch("name")
label("subquery").fetch(TypeQL.match(...).fetch(...))
Fetching multiple attributes without relabeling, before:
cVar("x").fetch(list(pair("name", null), pair("age", null), pair("dob", null)))
Usage now:
cVar("x").fetch("name", "age", "dob")
Add helper method to create Sorting modifier with just one argument
ProjectionBuilder for fetch queries
Renamed projection builder 'map()' to 'fetch()' and dissolved Stream overload
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.typedb.com</id>
<url>https://repo.typedb.com/public/public-release/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.27.0-rc0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.27.0-rc0</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.27.0-rc0
Refactor TypeQL Java projection builder
We note a previous change in 2eef07d388391e073cc1631f5af2bbf15e844cc4 and extend it here to refactor the TypeQL Fetch projection query builder:
Usage rename, before:
cVar("x").map("name")
label("subquery").map(TypeQL.match(...).fetch(...))
Usage now:
cVar("x").fetch("name")
label("subquery").fetch(TypeQL.match(...).fetch(...))
Fetching multiple attributes without relabeling, before:
cVar("x").fetch(list(pair("name", null), pair("age", null), pair("dob", null)))
Usage now:
cVar("x").fetch("name", "age", "dob")
Add helper method to create Sorting modifier with just one argument
ProjectionBuilder for fetch queries
Renamed projection builder 'map()' to 'fetch()' and dissolved Stream overload
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.typedb.com</id>
<url>https://repo.typedb.com/public/public-release/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.26.6</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.26.6</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.26.6
Implement non-ascii variables in Java and Rust We update to TypeQL with Unicode support in both value and concept variables. This makes the following valid TypeQL:
match $人 isa person, has name "Liu"; get $人;
match $אדם isa person, has name "Solomon"; get $אדם;
We now require all Labels and Variables are valid unicode identifiers not starting with _
.
This change is fully backwards compatible. We also validate that Type Labels and Variables created using the TypeQL language builders in both Rust and Java are conforming to our Unicode specification.
Fix snapshot version in test-deployment-maven
We update the generated snapshot version in test-deployment-maven CI job to correspond to the updated snapshot version format.
Allow variables to have a leading digit
We modify the behaviour of #310 which unified variables and labels to have the same valid identifier syntax, which eliminated the capability of variables to have a leading number. For example, the variable $0
was banned.
This PR reverts this specific behaviour, and enables usage of variables with leading digits:
match
$1_a isa entity;
get;
is made valid again.
Testing specified in https://github.com/vaticle/typedb-behaviour/pull/281
Merge typedb-common repository into typeql
As part of the effort to reduce the number of vaticle organization repositories, we merge typedb-common into the typeql repo as a subpackage.
Sync dependencies in CI
We add a sync-dependencies job to be run in CI after successful snapshot and release deployments. The job sends a request to vaticle-bot to update all downstream dependencies.
Note: this PR does not update the dependencies
repo dependency. It will be updated automatically by the bot during its first pass.
Set up CI filters for master-development workflow
Migrate artifact hosting to cloudsmith Updates artifact deployment & consumption rules to use cloudsmith instead of the self-hosted sonatype repository.
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.typedb.com</id>
<url>https://repo.typedb.com/public/public-release/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.26.6-rc0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.26.6-rc0</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.26.6-rc0
Implement non-ascii variables in Java and Rust We update to TypeQL with Unicode support in both value and concept variables. This makes the following valid TypeQL:
match $人 isa person, has name "Liu"; get $人;
match $אדם isa person, has name "Solomon"; get $אדם;
We now require all Labels and Variables are valid unicode identifiers not starting with _
.
This change is fully backwards compatible. We also validate that Type Labels and Variables created using the TypeQL language builders in both Rust and Java are conforming to our Unicode specification.
Fix snapshot version in test-deployment-maven
We update the generated snapshot version in test-deployment-maven CI job to correspond to the updated snapshot version format.
Merge typedb-common repository into typeql
As part of the effort to reduce the number of vaticle organization repositories, we merge typedb-common into the typeql repo as a subpackage.
Sync dependencies in CI
We add a sync-dependencies job to be run in CI after successful snapshot and release deployments. The job sends a request to vaticle-bot to update all downstream dependencies.
Note: this PR does not update the dependencies
repo dependency. It will be updated automatically by the bot during its first pass.
Set up CI filters for master-development workflow
Migrate artifact hosting to cloudsmith Updates artifact deployment & consumption rules to use cloudsmith instead of the self-hosted sonatype repository.
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.vaticle.com</id>
<url>https://repo.vaticle.com/repository/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.25.8</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.25.8</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.25.8
Technical debt: improve error_messages, cleanup
error_messages!
now accepts struct enum variants, rather than tuple variants. This forces the user to name the fields and to refer to the fields by name in the format strings, reducing user error.
Update README.md
Update readme: fix the forum badge
Update the readme file to fix the forum badge.
Fixed badges in README.md to refer to TypeQL
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.vaticle.com</id>
<url>https://repo.vaticle.com/repository/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.25.0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.25.0</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.25.0
One breaking change is implemented:
Match-Get
queries used to be implicit if the get
was ommitted. We now require the get
be explicitly written out. For example:match $x isa entity;
must now be written as:
match $x isa entity; get; # or get $x;
One new type is added:
Match-Fetch
queries are now available as both builders and parsed queries.Implement TypeQL Fetch query
We implement a new type of query: the Fetch
query. This type of query does three things:
The terminology we use to decribe 'fetch' clauses is that each entry in the 'fetch' is a projection.
Examples
match
$movie-type sub movie; # movie or its subtypes
$x isa! $movie-type, # an entity instance of the type
has title "Godfather",
has release-date $date,
has duration-minutes $mins;
?duration-hours = $mins / 60.0;
fetch
$movie-type;
$date;
?duration-hours;
match
$movie-type sub movie;
$x isa! $movie-type,
has title "Godfather",
has release-date $date,
has duration-minutes $mins;
?duration-hours = $mins / 60.0;
fetch
$movie-type as "movie category"; # set the key to return $movie-types as to "movie category"
$date as "release date"; # ...
?duration-hours as "length"; # ...
3a. Fetching extra data in the form of attributes. We use this to project an entity or relation into 'data' objects such as attributes, values, and types.
match
$x isa movie,
has title "Godfather",
has release-date $date;
fetch
$x: title, duration-minutes as "length";
$date as "release-date";
3b. Fetching extra data in the form of subqueries:
match
$x isa movie,
has title "Godfather",
has release-date $date;
fetch
$x: title, duration-minutes as "length";
$date as "release-date";
director-details: { # for each movie found, we will also get all the directors and fetch them as name and age
match
($x, $director) isa directorship;
fetch
$director: name, age;
};
director-count: { # for each movie found, we will retrieve the count of all directors for the movie
match
($x, $director) isa directorship;
get $director;
count;
};
TypeQL Fetch Query Builders
We also implement programmatic TypeQL builders for both Java and Rust. Without too much detail, here is how one would programmatically generate the query from 3b in Java and Rust builders:
Java
TypeQLFetch expected = match(
cVar("x").isa("movie").has("title", "Godfather").has("release-date", cVar("date"))
).fetch(
cVar("date").asLabel("release date"), // $date as "release date"
cVar("x").map("title").map("duration-minutes", "length"), // $x: title, duration-minutes as "length"
label("director-details").map( // subquery 'director-details'
match(
rel(cVar("x")).rel(cVar("director")).isa("directorship")
).fetch(
cVar("director").map("name").map("age")
)
),
label("directors-count").map( // subquery 'director-count'
match(
rel(cVar("x")).rel(cVar("director")).isa("directorship")
).get(cVar("director")).count()
)
);
Rust
let projections: Vec<Projection> = vec![
cvar("date").label("release date").into(), // $date as "release date"
cvar("x").map_attributes(vec![ // $x: title, duration-minutes as "length"
"title".into(),
("duration-minutes", "length").into(),
]),
label("director-details").map_subquery_fetch( // subquery 'director-details'
typeql_match!(
rel(cvar("x")).rel(cvar("director")).isa("directorship")
).fetch(vec![
cvar("director").map_attribute(vec!["name".into(), "age".into()])
])
),
label("director-count").map_subquery_get_aggregate( // subquery 'director-count'
typeql_match!(
rel(cvar("x")).rel(cvar("director")).isa("directorship")
).get_fixed([cvar("director")]).count()
)
];
let typeql_fetch = typeql_match!(
cvar("x").isa("movie").has(("title", "Godfather")).has(("release-date", cvar("date")))
).fetch(projections);
Important TypeQL Changes
To help enforce when a 'Get' and 'Fetch' query is being issued, we now require that the 'get' clause is mandatory in Get
queries, and rename what used to be considered a "Match" query to be a "Get" query.
The mental model we encourage is that the 'match' clause of a query is the definition/constraint space to search, and the following clause is the operation over that space - for example get (without transformation), fetch (transformation), insert, delete, update, etc.
Update README file
Update the README file.
Update root checkstyle to exclude banner
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.vaticle.com</id>
<url>https://repo.vaticle.com/repository/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.24.11</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.24.11</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.24.11
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.vaticle.com</id>
<url>https://repo.vaticle.com/repository/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.24.8</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.24.8</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.24.8
Update pest 2.4.0 => 2.7.4
We update to pest and pest-derive v2.7.4, which among other things purports to fix the error where deriving Parser fails on "undeclared crate or module alloc
" (https://github.com/pest-parser/pest/pull/900).
Replace vaticle.com with typedb.com
Update release notes
Available through https://crates.io/crates/typeql.
cargo add [email protected]
<repositories>
<repository>
<id>repo.vaticle.com</id>
<url>https://repo.vaticle.com/repository/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.24.5</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.24.5</version>
</dependency>
</dependencies>
Available through https://pypi.org
pip install typeql-grammar==2.24.5