Releases: typedb/typeql
TypeQL 3.0.0
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
New Features
-
TypeQL 3.0
User-defined functions and structs:
fun mean_salary($c: company) -> double? : match (company: $c, employee: $_) isa employment, has salary $s; return mean($s);
struct dated_coordinate: longitude value double, latitude value double, date value datetime;
Query pipelines:
with fun costliest_printer($employee: employee) -> printer? : match ($printer, $employee) isa print_permission; $printer has cost_per_page $cost; sort $cost desc; return first($printer); match $printer isa printer, has office_number $n, has newly_installed true; $employee isa employee, has office_number $n; put ($employee, $printer) isa print_permission; match $high_cost_printer = costliest_printer($employee), has printer_name $name; not { $printer is $high_cost_printer; }; $employee has contact $address; insert $notice isa queued_email, has recipient $address, has content "Do you still need the printer " + $name + "?";
New undefine syntax allows user to be more precise as to what is being undefined:
undefine owns age from person; @regex from first-name; as name from person owns first-name;
New, more concise delete syntax:
match $p isa person, has name $n; delete $n of $p;
Implement JSON-like string unescaping (closes #106).
See The TypeDB 3.0 Roadmap for more details!
-
[3.0] Change plays override from label to named_type to allow both scoped and not scoped labels
Previously, we could only use not scoped labels (names without scopes) in
as
ofplays
. However, it can cause troubles while reading the schema by a human eye:define relation family relates father; relation fathership relates father; entity person plays family:father, plays fathership:father; # It is fine: we can't have another "relates father" in family or fathership relation subfamily sub family, relates subfather as father; relation subfathership sub fathership, relates subfather as father; # It creates more questions as subperson can play multiple `father`s entity subperson sub person, plays subfamily:subfather as father, plays subfathership:subfather as father;
This PR allows us to use both
entity subperson sub person, plays subfamily:subfather as family:father, plays subfathership:subfather as fathership:father;
and
entity subperson sub person, plays subfamily:subfather as father, plays subfathership:subfather as father;
based on users' preferences. -
TypeQL 3 grammar enhancements
- New rich
fetch
syntax (see below). - Standardise the vocabulary of
pipeline
,stage
,clause
,operator
. A pipeline consists of stages. Each stage may be an operator, which modifies the data stream without accessing the database (e.g.count
,mean($x)
), or a clause, which may fetch data from the database to modify the stream (e.g.match
,fetch
). list()
stream reduce operator.$x in [$a, $b, $c]
and other list expressions now allowed inin
-statements (previously stream-only)
New
fetch
syntax sample... # incoming pipeline fetch { # Printing values directly from pipeline "key_1": $x, # var $x (from input stream) holds a value or list "key_2": <EXPR>, # <EXPR> is an expression like $x + $y # Inline attribute retrieval variations "key_3": $y.attr, # var $y holds an object with singleton attribute 'attr' "key_4": [ $y.attr ], # object var $y has multiple attributes 'attr' "key_5": $y.attr[], # object var $y has a list attribute 'attr' # Function call variations "key_6": my_fun1($x,$y), # function my_fun1 has single-return "key_7": [ my_fun2($x,$y) ], # function my_fun2 has stream-return # Match-fetch subqueries "key_8": [ match ...; fetch { "sub_key": $z, ... }; ] # Match-reduce-value subqueries "key_9": match ...; reduce agg($z); # agg could be, e.g., 'count', 'sum', or 'list' # Nested keys: Nothing stops you from nesting the above! "super_key": { "sub_key_1": $x, "sub_key_2": $y.attr, "sub_key_3": [ ... # some subquery ] } };
- New rich
-
Update syntax for reduce stages in pipelines
Update syntax for reduce stages in pipelines. Example:reduce $max = max($of1), $sum = sum($of2) within ($group, $variables)
-
Implement full fetch specification
We refactor Fetch and Function behaviour, to allow any of the following Fetching patterns:
match ... fetch { // fetch a matched attribute, value, or type. Represented as a attribute/value/type or null (if the variable is optional). "single variable": $a, // attribute 'age' of $x. Must be `@card(0..1)` or `@card(1..1)`. Represented as an attribute or null. "single-card attributes": $x.age, // all attributes 'name' of $x. Can be any cardinality. "list higher-card attributes": [ $x.name ], // inline-computed expression value. Represented as a value. "single value expression": $a + 1, // an inline query with a 'return' block to select a *single* answer. Represented identically to a single variable or null. "single answer block": ( match $x has name $name; return first $name; ), // an inline query with a 'return' block to reduce to a *single* answer. Represented as a value or null "reduce answer block": ( match $x has name $name; return count($name); ), // an inline query that returns a stream of lists/tuples. Represented as list of lists. "list positional return block": [ match $x has name $n, has age $a; return { $n, $a }; ], // an inline query that returns stream of sub-documents. Represented as a list of objects. "list pipeline": [ match $x has name $n, has age $a; fetch { "name": $n }; ], // special syntax to fetch all attributes of a concept. Represented as an object, where keys are attribute type names and values are either lists (for >card(1)) or nullable values (for card(0..1) or card(1..1)) "all attributes": { $x.* } }
-
Implement require operator
Implement the 'require' clause:
match ... require $x, $y, $z;
Will filter the match output stream to ensure that the variable
$x, $y, $z
are all non-empty variables (if they are optional). -
Introduce Reduce keyword for stream reduction operations
We introduce the missing
reduce
keyword for operations likemin/max/count
aggregations, as well asfirst()
andcheck
. However, we do not require thereduce
keyword for function return statements:match ... reduce count($x);
in a function would be;
define fun test(...) -> long: match ... return count($x);
We also allow trailing commas throughout the grammar, though they are ignored, to allow the user to generate queries more simply:
match $x, isa person, has name $n, ... ; #equivalent to the user-friendly syntax: $x isa person, has name, ...;
-
**Fill in some Display traits & fetch refactor for fetch ***
We fill in missing Display and Pretty printing traits -- note Struct destructuring and Functions are still not implemented.
We also add a new special syntax to fetch all attributes, since
attribute
is no longer a supertype of all attributes:fetch { "attrs": { $x.* } }
-
Implement duration literal parsing
Code Refactors
-
TypeQL syntax updates
Addslet
keyword before assignments & moves the constraint on anisa
to the end. E.g.$x isa marriage ($a, $b)
-
Rename override to specialise. Remove specialisations for owns and plays
Rename override to specialise. Remove specialisations for owns and plays respecting the server's changes: typedb/typedb#7157 -
Low hanging optimisations for TypeQL
Low hanging optimisations for TypeQL -
Make Is statement fields public
We make the
lhs
andrhs
fields of theIs
statement struct public for use in typedb core. -
Expose some extra fields in statements
Expose some more required fields. -
Update fields used by function builders in core to be public
Updates fields used by function builders in core to be public.
Other Improvements
-
Make iid field public
-
Update maven snapshot
We update the maven artifacts snapshot for build dependency test.
-
Reorder fetch variants to prioritize the fetch stream for functions over the list of expressions
We reorder fetch variants to prioritize the fetch stream for functions over the list of expressions. The old ordering led to incorrect parsing of fetch statements with listed function calls. -
Commit generated Cargo.toml
We commit the generated cargo manifests so that
typeql
can be used as a cargo git dependency. -
Add unescape version for regex annotations
We add a separateunescape
method for strings insideregex
annotations to preserve regex escaped characters and unescape"
quotes. -
autogenerated grammar visitor tests
TypeQL 2.28.6
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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.6</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.28.6</version>
</dependency>
</dependencies>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.28.6
New Features
Bugs Fixed
Code Refactors
Other Improvements
-
Use Universe manifest for features & version ranges of crates.io dependencies (#353)
-
Merge master into development after 2.28.5 release
TypeQL 2.28.5
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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.5</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.28.5</version>
</dependency>
</dependencies>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.28.5
New Features
Bugs Fixed
Code Refactors
Other Improvements
-
Make the author of the Python grammar and TypeQL Rust "TypeDB Community"
The
author
field of our Python grammar and Rust library is now TypeDB Community with the email being [email protected]. -
Update error messages to match Rust and Java implementations
We fixed various logical and grammatical issues in the Java and Rust error messages, aiming to have similar errors from both implementations. -
Java and Rust error messages: grammatical fixes
We fixed various grammatical issues in the Java and Rust error messages.
-
Update readme
TypeQL 2.28.1
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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.1</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.28.1</version>
</dependency>
</dependencies>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.28.1
Other Improvements
- Bump snake-yaml maven dependency to 2.2
Bump snake-yaml maven dependency to 2.2
TypeQL 2.28.0
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.28.0
New Features
Bugs Fixed
Code Refactors
Other Improvements
-
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.
TypeQL 2.27.0
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.27.0
New Features
Bugs Fixed
Code Refactors
-
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")
Other Improvements
-
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
TypeQL 2.27.0-rc0
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.27.0-rc0
New Features
Bugs Fixed
Code Refactors
-
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")
Other Improvements
-
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
TypeQL 2.26.6
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.26.6
New Features
-
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.
Bugs Fixed
-
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.
Code Refactors
-
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 typedb/typedb-behaviour#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.
Other Improvements
-
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.
TypeQL 2.26.6-rc0
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.26.6-rc0
New Features
-
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.
Bugs Fixed
-
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.
Code Refactors
-
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.
Other Improvements
-
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.
TypeQL 2.25.8
TypeQL Grammar and Language Library distributions for Rust
Available through https://crates.io/crates/typeql.
cargo add [email protected]
TypeQL Grammar and Language Library distributions for Java
<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>
TypeQL Grammar distribution for Python
Available through https://pypi.org
pip install typeql-grammar==2.25.8
New Features
Bugs Fixed
Code Refactors
-
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.
Other Improvements
-
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