Skip to content

Commit

Permalink
feat: support for simple extensions dependencies (#265)
Browse files Browse the repository at this point in the history
Co-authored-by: David Sisson <[email protected]>
  • Loading branch information
jvanstraten and EpsilonPrime authored Nov 22, 2023
1 parent 9c53a93 commit f0ecf54
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions site/docs/extensions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@ A Substrait plan can reference one or more YAML files via URI for extension. In
| Type Variation | The name as defined on the type variation object. |
| Function Signature | A function signature compound name as described below. |

A YAML file can also reference types and type variations defined in another YAML file. To do this, it must declare the YAML file it depends on using a key-value pair in the `dependencies` key, where the value is the URI to the YAML file, and the key is a valid identifier that can then be used as an identifier-safe alias for the URI. This alias can then be used as a `.`-separated namespace prefix wherever a type class or type variation name is expected.

For example, if the YAML file at `file:///extension_types.yaml` defines a type called `point`, a different YAML file can use the type in a function declaration as follows:

```yaml
dependencies:
ext: file:///extension_types.yaml
scalar_functions:
- name: distance
description: The distance between two points.
impls:
- args:
- name: a
value: ext.point
- name: b
value: ext.point
return: f64
```
Here, the choice for the name `ext` is arbitrary, as long as it does not conflict with anything else in the YAML file.

### Function Signature Compound Names

A YAML file may contain one or more functions by the same name. The key used in the function extension declaration to reference a function is a combination of the name of the function along with a list of the required input argument types. The format is as follows:
Expand Down
10 changes: 10 additions & 0 deletions text/simple_extensions_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ title: Simple Extensions
additionalProperties: false
type: object
properties:
dependencies:
# For reusing type classes and type variations from other extension files.
# The keys are namespace identifiers that you can then use as dot-separated
# prefix for type class and type variation names in functions and the base
# type class for variations. The values must be extension URIs, following
# the same format and conventions as those used in the proto plans.
type: object
patternProperties:
"^[a-zA-Z_\\$][a-zA-Z0-9_\\$]*$":
type: string
types:
type: array
minItems: 1
Expand Down

0 comments on commit f0ecf54

Please sign in to comment.