Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for simple extensions dependencies #265

Merged
merged 4 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 | In a specific YAML, if there is only one function implementation with a specific name, a extension type declaration can reference the function using either simple or compound references. Simple references are simply the name of the function (e.g. `add`). Compound references (e.g. `add:i8_i8`)are 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. When only a single function is declared within the file, it can be referenced using the name of that function or a compound name. When more than one function of the same name is declared within a YAML file, the key used in the function extension declaration is a combination of the name of the function along with a list of 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 @@ -3,6 +3,16 @@ $schema: https://json-schema.org/draft/2020-12/schema
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
Loading