typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 44 forks source link

Toggling infer retrieves explainables when explain is not enabled #650

Closed mathieuisabel closed 1 year ago

mathieuisabel commented 1 year ago

Description

When running a query triggering inference rules with inference mode On, the server doesn't seem to respect the variables specified in the get clause.

Environment

  1. OS (where TypeDB server runs): Windows 11
  2. TypeDB version (and platform): typedb-all-windows-33c994376526dde9238bb75643d488780479ee16
  3. TypeDB client: typedb studio 2.11.1
  4. Other environment details:

Reproducible Steps

Steps to create the smallest reproducible scenario: Run a query that triggers an inference rule and only specify one variable in the get clause.

i.e. match
$p isa processor, has name $p-name; $icq (qualified: $p, measurement-instance: $mi, category: $pcq) isa inferred-performance-categorization-qualification; $pcq-name = "Best Performance CPU";
get $p-name;

Returns a lot of other things: image

image

Expected Output

Only the variable specified is returned.

Actual Output

All variables are returned.

Additional information

mathieuisabel commented 1 year ago

I had mentioned that in DIscord a little while back but logging here just in case.

flyingsilverfin commented 1 year ago

@jamesreprise i think you had investigated this in Studio? I'm going to move it to the Studio repository for now :)

jamesreprise commented 1 year ago

I had mentioned that in DIscord a little while back but logging here just in case.

Hi Mathieu, I remember us fixing this in Discord together. Many thanks for the report there. This will be out in the next release (which we're doing fairly soon).

If it's any help, this is fixed in the development branch and we provide instructions to build and run from source there - let us know if you have any trouble in doing so.

mathieuisabel commented 1 year ago

I'm not sure I understand why it's a Studio bug. i.e. Is it changing the query to retrieve more than the original query executed?

jamesreprise commented 1 year ago

I'm not sure I understand why it's a Studio bug. i.e. Is it changing the query to retrieve more than the original query executed?

There was an oversight in how we processed infer (but not explain) queries. When infer was enabled but explain wasn't, we would still act as though explain was enabled and retrieve all the concepts required to explain the relation.

Here's the code, if you're interested: https://github.com/vaticle/typedb-studio/pull/633/files#diff-636c86f89c03326c6fe2c585c7b100225ac163b3f8b9ee29a3dd80fff6e12324R101

We've also added a regression test to ensure that this bug does not re-occur, see the full content of:

jamesreprise commented 1 year ago

This issue has been resolved and is fixed in the latest release of Studio! Let us know if you have any issues with this in the future.