From 99bb18d66a631c379b8b021c2a10aa85205e182b Mon Sep 17 00:00:00 2001 From: Jeroen van Straten Date: Tue, 26 Jul 2022 14:50:53 +0200 Subject: [PATCH 1/4] feat: support for simple extensions dependencies --- text/simple_extensions_schema.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 From e2156181c60262d04f6066e2c2f0f1d8f2c9f46a Mon Sep 17 00:00:00 2001 From: Jeroen van Straten Date: Mon, 15 Aug 2022 12:42:56 +0200 Subject: [PATCH 2/4] docs: document YAML-to-YAML dependencies --- site/docs/extensions/index.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/site/docs/extensions/index.md b/site/docs/extensions/index.md index e75b56bc6..e3081b12b 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 `/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: /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: From c6727881ee0d69ee0e93658dc9f89ae48a8b35cf Mon Sep 17 00:00:00 2001 From: David Sisson Date: Wed, 27 Sep 2023 19:47:07 -0700 Subject: [PATCH 3/4] Add file: to the local URI example --- site/docs/extensions/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/docs/extensions/index.md b/site/docs/extensions/index.md index e3081b12b..2a5130f86 100644 --- a/site/docs/extensions/index.md +++ b/site/docs/extensions/index.md @@ -25,11 +25,11 @@ A Substrait plan can reference one or more YAML files via URI for extension. In 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 `/extension_types.yaml` defines a type called `point`, a different YAML file can use the type in a function declaration as follows: +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: /extension_types.yaml + ext: file:/extension_types.yaml scalar_functions: - name: distance description: The distance between two points. From c88c11c2035f4cdc4f369767417b89eb41d3735d Mon Sep 17 00:00:00 2001 From: David Sisson Date: Wed, 22 Nov 2023 10:25:56 -0800 Subject: [PATCH 4/4] Add missing slashes --- site/docs/extensions/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site/docs/extensions/index.md b/site/docs/extensions/index.md index 2a5130f86..3bfa9b013 100644 --- a/site/docs/extensions/index.md +++ b/site/docs/extensions/index.md @@ -25,11 +25,11 @@ A Substrait plan can reference one or more YAML files via URI for extension. In 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: +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 + ext: file:///extension_types.yaml scalar_functions: - name: distance description: The distance between two points.