Skip to content

Commit

Permalink
Merge for 2.27.0-rc0 release (#324)
Browse files Browse the repository at this point in the history
## Usage and product changes

We merge development into master for 2.27.0-rc0 release.
  • Loading branch information
typedb-bot authored Mar 14, 2024
2 parents 9e89657 + 2e052e2 commit 9a3e44b
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 108 deletions.
83 changes: 31 additions & 52 deletions RELEASE_NOTES_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Available through https://crates.io/crates/typeql.
```
cargo add typeql@2.26.6
cargo add typeql@2.27.0-rc0
```

## TypeQL Grammar and Language Library distributions for Java
Expand All @@ -20,12 +20,12 @@ cargo add [email protected]
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-grammar</artifactId>
<version>2.26.6</version>
<version>2.27.0-rc0</version>
</dependency>
<dependency>
<groupId>com.vaticle.typeql</groupId>
<artifactId>typeql-lang</artifactId>
<version>2.26.6</version>
<version>2.27.0-rc0</version>
</dependency>
</dependencies>
```
Expand All @@ -35,68 +35,47 @@ cargo add [email protected]
Available through https://pypi.org

```
pip install typeql-grammar==2.26.6
pip install typeql-grammar==2.27.0-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:


## Bugs Fixed


## Code Refactors
- **Refactor TypeQL Java projection builder**

We note a previous change in [2eef07d388391e073cc1631f5af2bbf15e844cc4](https://github.com/vaticle/typeql/commit/2eef07d388391e073cc1631f5af2bbf15e844cc4) and extend it here to refactor the TypeQL Fetch projection query builder:

Usage rename, before:
```
match $人 isa person, has name "Liu"; get $人;
cVar("x").map("name")
label("subquery").map(TypeQL.match(...).fetch(...))
```

Usage now:
```
match $אדם isa person, has name "Solomon"; get $אדם;
cVar("x").fetch("name")
label("subquery").fetch(TypeQL.match(...).fetch(...))
```

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:
Fetching multiple attributes without relabeling, before:
```
match
$1_a isa entity;
get;
cVar("x").fetch(list(pair("name", null), pair("age", null), pair("dob", null)))
```
Usage now:
```
cVar("x").fetch("name", "age", "dob")
```
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.


## 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**
- **Add helper method to create Sorting modifier with just one argument**

- **Migrate artifact hosting to cloudsmith**
Updates artifact deployment & consumption rules to use cloudsmith instead of the self-hosted sonatype repository.





- **ProjectionBuilder for fetch queries**

- **Renamed projection builder 'map()' to 'fetch()' and dissolved Stream overload**

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.26.6
2.27.0-rc0
2 changes: 1 addition & 1 deletion dependencies/maven/artifacts.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@maven//:org_checkerframework_checker_qual_3_5_0
@maven//:org_hamcrest_hamcrest_core_1_3
@maven//:org_hamcrest_hamcrest_library_1_3
@maven//:org_jetbrains_compose_compiler_compiler_1_3_2
@maven//:org_jetbrains_compose_compiler_compiler_1_5_7
@maven//:org_jsoup_jsoup_1_16_1
@maven//:org_slf4j_slf4j_api_2_0_0
@maven//:org_yaml_snakeyaml_1_25
Expand Down
4 changes: 2 additions & 2 deletions dependencies/vaticle/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ def vaticle_dependencies():
git_repository(
name = "vaticle_dependencies",
remote = "https://github.com/vaticle/dependencies",
commit = "08d4e3bafb5a90db76eb5188be6f90bee564eb01", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
commit = "41f7b9c7a26c06942447e446e46f7071ae610ae7", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_dependencies
)

def vaticle_typedb_behaviour():
git_repository(
name = "vaticle_typedb_behaviour",
remote = "https://github.com/vaticle/typedb-behaviour",
commit = "f996fb7322eabfaafdbbf203a59fdc27fd6babf0", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
commit = "c607ac62ac5375021e0ed728b015ccb5fe8a8d3b", # sync-marker: do not remove this comment, this is used for sync-dependencies by @vaticle_typedb_behaviour
)
9 changes: 4 additions & 5 deletions java/builder/ConceptVariableBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@
import com.vaticle.typeql.lang.pattern.statement.builder.TypeStatementBuilder;
import com.vaticle.typeql.lang.query.TypeQLFetch;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.vaticle.typedb.common.collection.Collections.list;

Expand Down Expand Up @@ -193,12 +192,12 @@ public LabelledVar asLabel(TypeQLFetch.Key.Label label) {
}

@Override
public Attribute map(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute) {
public Attribute fetch(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute) {
return new Attribute(this, list(attribute));
}

@Override
public Attribute map(Stream<Pair<Reference.Label, TypeQLFetch.Key.Label>> attributes) {
return new Attribute(this, attributes.collect(Collectors.toList()));
public Attribute fetch(List<Pair<Reference.Label, Label>> attributes) {
return new Attribute(this, attributes);
}
}
9 changes: 4 additions & 5 deletions java/builder/ValueVariableBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
import com.vaticle.typeql.lang.pattern.statement.builder.ValueStatementBuilder;
import com.vaticle.typeql.lang.query.TypeQLFetch;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.vaticle.typedb.common.collection.Collections.list;

Expand Down Expand Up @@ -86,12 +85,12 @@ public LabelledVar asLabel(TypeQLFetch.Key.Label label) {
}

@Override
public Attribute map(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute) {
public Attribute fetch(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute) {
return new Attribute(this, list(attribute));
}

@Override
public Attribute map(Stream<Pair<Reference.Label, TypeQLFetch.Key.Label>> attributes) {
return new Attribute(this, attributes.collect(Collectors.toList()));
public Attribute fetch(List<Pair<Reference.Label, Label>> attributes) {
return new Attribute(this, attributes);
}
}
3 changes: 1 addition & 2 deletions java/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
import static com.vaticle.typeql.lang.common.exception.ErrorMessage.ILLEGAL_GRAMMAR;
import static com.vaticle.typeql.lang.common.exception.ErrorMessage.ILLEGAL_STATE;
import static com.vaticle.typeql.lang.common.util.Strings.unescapeRegex;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import static org.antlr.v4.runtime.atn.PredictionMode.LL_EXACT_AMBIG_DETECTION;
import static org.antlr.v4.runtime.atn.PredictionMode.SLL;
Expand Down Expand Up @@ -921,7 +920,7 @@ public TypeQLFetch.Projection visitProjection(TypeQLParser.ProjectionContext ctx
if (ctx.projection_attributes() == null) {
return key;
} else {
return key.map(visitProjection_attributes(ctx.projection_attributes()).stream());
return key.fetch(visitProjection_attributes(ctx.projection_attributes()));
}
} else if (ctx.projection_key_label() != null && ctx.projection_subquery() != null) {
return new TypeQLFetch.Projection.Subquery(
Expand Down
12 changes: 6 additions & 6 deletions java/parser/test/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -869,17 +869,17 @@ public void testFetchQuery() {
).fetch(
cVar("d"),
cVar("d").asLabel("date"),
cVar("x").map("name").map("title", "t").map("name", "Movie name"),
cVar("x").asLabel("movie").map("name"),
cVar("x").asLabel("Movie name").map("name"),
label("label-a").map(
cVar("x").fetch("name").fetch("title", "t").fetch("name", "Movie name"),
cVar("x").asLabel("movie").fetch("name"),
cVar("x").asLabel("Movie name").fetch("name"),
label("label-a").fetch(
match(
rel(cVar("d")).rel(cVar("c")).isa("director")
).fetch(
cVar("d").map("name")
cVar("d").fetch("name")
)
),
label("label-b").map(
label("label-b").fetch(
match(
rel(cVar("d")).rel(cVar("c")).isa("director")
).get(cVar("d")).count()
Expand Down
16 changes: 8 additions & 8 deletions java/query/TypeQLFetch.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.Optional;
import java.util.stream.Stream;

import static com.vaticle.typedb.common.collection.Collections.concatToList;
import static com.vaticle.typedb.common.collection.Collections.list;
import static com.vaticle.typedb.common.util.Objects.className;
import static com.vaticle.typeql.lang.common.TypeQLToken.Char.COLON;
Expand All @@ -51,7 +52,6 @@
import static com.vaticle.typeql.lang.pattern.Pattern.validateNamesUnique;
import static com.vaticle.typeql.lang.query.TypeQLQuery.appendClause;
import static com.vaticle.typeql.lang.query.TypeQLQuery.appendModifiers;
import static java.util.stream.Collectors.toList;

public class TypeQLFetch implements TypeQLQuery {

Expand Down Expand Up @@ -287,13 +287,13 @@ public LabelledVar key() {
}

@Override
public Attribute map(Pair<Reference.Label, Label> attribute) {
public Attribute fetch(Pair<Reference.Label, Label> attribute) {
return new Attribute(this, list(attribute));
}

@Override
public Attribute map(Stream<Pair<Reference.Label, Label>> attributes) {
return new Attribute(this, attributes.collect(toList()));
public Attribute fetch(List<Pair<Reference.Label, Label>> attributes) {
return new Attribute(this, attributes);
}

@Override
Expand Down Expand Up @@ -384,7 +384,7 @@ public int hashCode() {
}

@Override
public Projection.Subquery map(Either<TypeQLFetch, TypeQLGet.Aggregate> subquery) {
public Projection.Subquery fetch(Either<TypeQLFetch, TypeQLGet.Aggregate> subquery) {
return new Projection.Subquery(this, subquery);
}
}
Expand Down Expand Up @@ -452,13 +452,13 @@ public Key.Var key() {
}

@Override
public Attribute map(Pair<Reference.Label, Key.Label> attribute) {
public Attribute fetch(Pair<Reference.Label, Key.Label> attribute) {
return new Attribute(key(), list(attributes, attribute));
}

@Override
public Attribute map(Stream<Pair<Reference.Label, Key.Label>> attributes) {
return new Attribute(key(), Stream.concat(this.attributes.stream(), attributes).collect(toList()));
public Attribute fetch(List<Pair<Reference.Label, Key.Label>> attributes) {
return new Attribute(key(), concatToList(this.attributes, attributes));
}

public List<Pair<Reference.Label, Key.Label>> attributes() {
Expand Down
4 changes: 4 additions & 0 deletions java/query/TypeQLQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,10 @@ private Sorting(List<TypeQLVariable> variables, Map<TypeQLVariable, TypeQLArg.Or
this.hash = Objects.hash(variables, orders);
}

public static Sorting create(Pair<TypeQLVariable, TypeQLArg.Order> sorting) {
return create(list(sorting));
}

public static Sorting create(List<Pair<TypeQLVariable, TypeQLArg.Order>> sorting) {
List<TypeQLVariable> vars = new ArrayList<>();
Map<TypeQLVariable, TypeQLArg.Order> orders = new HashMap<>();
Expand Down
40 changes: 20 additions & 20 deletions java/query/builder/ProjectionBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,48 +28,48 @@
import com.vaticle.typeql.lang.query.TypeQLGet;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public interface ProjectionBuilder {

interface Attribute {

default TypeQLFetch.Projection.Attribute map(String attribute) {
return map(Reference.label(attribute));
default TypeQLFetch.Projection.Attribute fetch(String... attributes) {
return fetch(Stream.of(attributes)
.map(attr -> new Pair<>(Reference.label(attr), (TypeQLFetch.Key.Label) null))
.collect(Collectors.toList()));
}

default TypeQLFetch.Projection.Attribute map(Reference.Label label) {
return map(new Pair<>(label, null));
default TypeQLFetch.Projection.Attribute fetch(Reference.Label... labels) {
return fetch(Stream.of(labels)
.map(label -> new Pair<>(label, (TypeQLFetch.Key.Label) null))
.collect(Collectors.toList()));
}

default TypeQLFetch.Projection.Attribute map(String attribute, String label) {
return map(Reference.label(attribute), TypeQLFetch.Key.Label.of(label));
default TypeQLFetch.Projection.Attribute fetch(String attribute, String label) {
return fetch(Reference.label(attribute), TypeQLFetch.Key.Label.of(label));
}

default TypeQLFetch.Projection.Attribute map(Reference.Label attribute, TypeQLFetch.Key.Label label) {
return map(new Pair<>(attribute, label));
default TypeQLFetch.Projection.Attribute fetch(Reference.Label attribute, TypeQLFetch.Key.Label label) {
return fetch(new Pair<>(attribute, label));
}

default TypeQLFetch.Projection.Attribute map(List<Pair<Reference.Label, TypeQLFetch.Key.Label>> attributes) {
return map(attributes.stream());
}

TypeQLFetch.Projection.Attribute map(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute);

TypeQLFetch.Projection.Attribute map(Stream<Pair<Reference.Label, TypeQLFetch.Key.Label>> attributes);
TypeQLFetch.Projection.Attribute fetch(List<Pair<Reference.Label, TypeQLFetch.Key.Label>> attributes);

TypeQLFetch.Projection.Attribute fetch(Pair<Reference.Label, TypeQLFetch.Key.Label> attribute);
}

interface Subquery {

default TypeQLFetch.Projection.Subquery map(TypeQLFetch fetch) {
return map(Either.first(fetch));
default TypeQLFetch.Projection.Subquery fetch(TypeQLFetch fetch) {
return fetch(Either.first(fetch));
}

default TypeQLFetch.Projection.Subquery map(TypeQLGet.Aggregate aggregate) {
return map(Either.second(aggregate));
default TypeQLFetch.Projection.Subquery fetch(TypeQLGet.Aggregate aggregate) {
return fetch(Either.second(aggregate));
}

TypeQLFetch.Projection.Subquery map(Either<TypeQLFetch, TypeQLGet.Aggregate> subquery);
TypeQLFetch.Projection.Subquery fetch(Either<TypeQLFetch, TypeQLGet.Aggregate> subquery);
}
}
6 changes: 3 additions & 3 deletions java/query/test/TypeQLQueryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ public void testFetchBuilder() {
cVar("x").isa("person").has("id", cVar("id"))
).fetch(
cVar("id"),
cVar("x").map("name").map("age").map("email"),
label("children").map(
cVar("x").fetch("name").fetch("age").fetch("email"),
label("children").fetch(
match(
rel(cVar("c")).rel(cVar("x")).isa("parenthood")
).fetch(
cVar("c").map("name")
cVar("c").fetch("name")
)
)
);
Expand Down
Loading

0 comments on commit 9a3e44b

Please sign in to comment.