dolthub / dolthub/dolt

Incorrect results for virtual column in `WHERE` or `ORDER BY`

Open
#8,323 0 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
bug correctness
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

Example 1:

```
create table test(pk int primary key, j int, value int as (pk*pk));
insert into test(pk, j) values (-1, 1), (2, 1), (-3, 1);
select value from test order by value;
```

Expected output:
```
+-------+
| value |
+-------+
| 1 |
| 4 |
| 9 |
+-------+
```

Actual output:
```
+-------+
| value |
+-------+
| NULL |
| NULL |
| NULL |
+-------+
```

Example 2:

```
create table test(pk int primary key, j int, k int, value int as (pk*pk));
insert into test(pk, j) values (-1, 1, 2), (2, 1, 2), (-3, 1, 2);
select value from test order by value;
```

Expected output:
```
+-------+
| value |
+-------+
| 1 |
| 4 |
| 9 |
+-------+
```

Actual output:
`unable to find field with index 2 in row of 2 columns`

In both cases, columns `j` and `k` are unused, but affect the outcome. If there are no non-virtual value columns, the query behaves correctly. Adding a second virtual column causes queries on both virtual columns to behave correctly.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.