diff --git a/site/docs/extensions/index.md b/site/docs/extensions/index.md index e75b56bc6..3bfa9b013 100644 --- a/site/docs/extensions/index.md +++ b/site/docs/extensions/index.md @@ -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: diff --git a/text/simple_extensions_schema.yaml b/text/simple_extensions_schema.yaml index 48be6ab6b..ea371db9a 100644 --- a/text/simple_extensions_schema.yaml +++ b/text/simple_extensions_schema.yaml @@ -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