Skip to content

Commit

Permalink
Merge pull request #1797 from dolthub/max/has-ancestor
Browse files Browse the repository at this point in the history
has ancestor docs
  • Loading branch information
max-hoffman authored Oct 20, 2023
2 parents 0331cd7 + 76815b3 commit d3d88cd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions content/reference/sql/version-control/dolt-sql-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ title: Dolt SQL Functions
- [dolt_merge_base()](#dolt_merge_base)
- [hashof()](#hashof)
- [dolt_version()](#dolt_version)
- [has_ancestor()](#has_ancestor)

- [Table Functions](#table-functions)

Expand Down Expand Up @@ -68,6 +69,30 @@ mysql> select dolt_version();
+----------------+
```

## `HAS_ANCESTOR()`

The `HASH_ANCESTOR(target, ancestor)` function returns a `boolean` indicating whether a
candidate `ancestor` commit is in the commit graph of the `target` ref.

Consider the example commit graph from above:

```text
A---B---C feature
/
D---E---F---G main
```

A hypothetic example where we substitute letters for commit
hashes would look like:

```sql
select has_ancestor('feature', 'A'); -- true
select has_ancestor('feature', 'E'); -- true
select has_ancestor('feature', 'F'); -- false
select has_ancestor('main', 'E'); -- true
select has_ancestor('G', 'main'); -- true
```

# Table Functions

Table functions operate like regular SQL functions, but instead of returning a single,
Expand Down

0 comments on commit d3d88cd

Please sign in to comment.