All Products
Search
Document Center

OpenSearch:TVF

Last Updated:Feb 28, 2024

Overview

OpenSearch Retrieval Engine Edition supports table-valued functions (TVFs).

In an SQL statement, you can use a TVF to perform an operation on a table. The inputs of a TVF include one or more scalar parameters and an SQL statement that specifies a table. The output of a TVF is a table.

Supported versions

OpenSearch Retrieval Engine Edition whose HA3 version is V3.7.4 or later

Syntax

SELECT:
  SELECT [ DISTINCT ]
    { * | projectItem [, projectItem ]* }
  FROM Table({TVF})
    [ WHERE booleanExpression ]
    [ GROUP BY { groupItem [, groupItem ]* } ]
    [ ORDER BY { orderByItem [, OrderByItem ]* }]
    [ HAVING booleanExpression ]
    [ LIMIT number]
    [ OFFSET number]

TVF:
        {TVF Name}({scalar parameter}*, {SELECT})

Examples

Specify a single TVF in a statement

SELECT
    *
FROM
    TABLE (
        one_part_tvf(
            'rtp_url',
            123,
            (
                SELECT i1, i2, d3, d4 FROM t1
            )
        )
    )

Specify multiple nested TVFs in a statement

You cannot specify nested TVFs in the following format:

SELECT
    *
from
    TABLE (
        tvf1(
            tvf2(
                (
                    select
                        *
                    from
                        t1
                )
            )
        )
    )

You can specify nested TVFs in the following format:

SELECT
    *
FROM
    TABLE (
        one_part_tvf_enable_shuffle(
            'rtp_url',
            123,
            (
                SELECT
                    i1, i2
                FROM
                    TABLE (
                        one_part_tvf_enable_shuffle(
                            'rtp_url_2',
                            234,
                            (
                                SELECT i1, i2, d3, d4 FROM t1
                            )
                        )
                    )
            )
        )
    )

Built-in TVFs

For more information, see Built-in TVFs.