dolthub / dolthub/dolt

`DOLT_LOG` behaves incorrectly when used in a lateral join.

Open
#9,995 0 comments 0 reactions 1 assignee Claimed by @nicktobey View on GitHub
bug sql version control
Dominant language
Go
Stars
24.4k
Forks
873
Avg merge
1d 5h
Merged PRs (30d)
108

Description

### Query

```sql
select l.commit_order as child, r.commit_order as parent from dolt_log() l join lateral (select * from dolt_log(l.commit_hash)) r;
```

### Expected behavior

For each commit, we expect a row for each of that commits parents.

So if there are four commits on the branch, we would expect to see this result:

```
+-------+--------+
| child | parent |
+-------+--------+
| 4 | 4 |
| 4 | 3 |
| 4 | 2 |
| 4 | 1 |
| 3 | 3 |
| 3 | 2 |
| 3 | 1 |
| 2 | 2 |
| 2 | 1 |
| 1 | 1 |
+-------+--------+
```

### Actual behavior

Instead, we get an error: `unable to find field with index 1 in row of 0 columns`

e5951800a4204fadf524b1e4231d08d12d636657 fixes this, but now we get the following incorrect results:

```
+-------+--------+
| child | parent |
+-------+--------+
| 4 | 4 |
| 4 | 3 |
| 4 | 2 |
| 4 | 1 |
| 3 | 4 |
| 3 | 3 |
| 3 | 2 |
| 3 | 1 |
| 2 | 4 |
| 2 | 3 |
| 2 | 2 |
| 2 | 1 |
| 1 | 4 |
| 1 | 3 |
| 1 | 2 |
| 1 | 1 |
+-------+--------+
```

It seems like the arguments to DOLT_LOG are being ignored if they aren't constant.

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.