Skip to main content

arguments

Definition

arguments is a property used in Veezoo's function configuration to specify the types and properties of the arguments that the function accepts. This property provides a framework to define the input parameters, thereby enabling the function to interact with various parts of the Knowledge Graph.

Usage

arguments is an array where each element describes an argument the function accepts. The order of the elements in the array corresponds to the order of the arguments. Each argument can be defined in several ways:

  • Directly as a type, like string or number.
  • As an object with type and single_value_only properties.

The type property is either a single type or an array of types that the argument can accept. For example, if an argument can be a number or a date, its type would be [number, date].

The single_value_only property is a boolean that indicates whether the argument accepts only single values. If single_value_only is true, the function accepts only literal values for this argument, not columns. This is useful for functions that require a constant value, such as a fixed date or a specific string.

Example

Let's consider the matches_regex function from our examples here. Here, arguments is used to define two arguments:

function matches_regex {
name: "matches regex"
// Rest of function definition...
arguments: [
{ type: [string, class] },
{ type: string, single_value_only: true}
]
// Rest of function definition...
}

In this example, the matches_regex function takes two arguments:

  1. The first argument is either a string or a class. Therefore, type is defined as an array with two elements: [string, class].
  2. The second argument is a string, but it must be a single value, not a column. Therefore, it's defined as an object with type: string and single_value_only: true.

When using the function, these arguments are provided in the same order as they are defined in the arguments array.

Guidelines

When defining arguments:

  • Make sure the arguments match the placeholders in the sql_select and sql_where properties.
  • Use the single_value_only property for arguments that need to be literal values.
  • If an argument can accept multiple types, define its type as an array of those types.

Remember, the arguments property is a key part of function definition, determining the types of data a function can operate on.