Yandex.Cloud
  • Services
  • Why Yandex.Cloud
  • Pricing
  • Documentation
  • Contact us
Get started
Yandex Database
  • Getting started
    • Overview
    • Create databases
    • Examples of YQL queries
    • Examples of operations in the YDB CLI
    • Launch a test app
    • Document API
    • Developing in NodeJS through the Document API
  • Step-by-step instructions
    • Database management
    • How to connect to a database
    • Table management
    • Reading and writing data
    • Working with secondary indexes
  • Working with the SDK
  • Concepts
    • Overview
    • Data model and schema
    • Serverless and Dedicated operation modes
    • Data types
    • Transactions
    • Secondary indexes
    • Time to Live (TTL)
    • Terms and definitions
    • Quotas and limits
  • Access management
  • Pricing policy
    • Overview
    • Serverless mode
    • Dedicated mode
  • Recommendations
    • Schema design
    • Partitioning tables
    • Secondary indexes
    • Paginated output
    • Loading large data volumes
    • Using timeouts
  • YDB API and API reference
    • Database limits
    • Handling errors in the API
  • Amazon DynamoDB-compatible HTTP API
    • API reference
      • All methods
      • Actions
        • BatchGetItem
        • BatchWriteItem
        • CreateTable
        • DeleteItem
        • DeleteTable
        • DescribeTable
        • GetItem
        • ListTables
        • PutItem
        • Query
        • Scan
        • TransactGetItems
        • TransactWriteItems
        • UpdateItem
      • Common errors
  • YQL reference guide
    • Overview
    • Data types
      • Simple
      • Optional
      • Containers
      • Special
    • Syntax
      • Unsupported statements
      • For text representation of data types
      • Expressions
      • CREATE TABLE
      • DROP TABLE
      • INSERT INTO
      • UPSERT INTO
      • REPLACE INTO
      • UPDATE
      • DELETE
      • SELECT
      • GROUP BY
      • JOIN
      • FLATTEN
      • ACTION
      • DISCARD
      • PRAGMA
      • DECLARE
      • OVER, PARTITION BY, and WINDOW
    • Built-in functions
      • Basic
      • Aggregate
      • Window
      • For lists
      • For dictionaries
      • For JSON
      • For structures
      • For types
    • Preset user-defined functions
      • HyperScan
      • Pcre
      • Pire
      • Re2
      • String
      • Unicode
      • Datetime
      • Url
      • Ip
      • Digest
      • Math
      • Histogram
    • For text representation of data types
  • YQL tutorial
    • Overview
    • Creating a table
    • Adding data to a table
    • Selecting data from all columns
    • Selecting data from specific columns
    • Sorting and filtering
    • Data aggregation
    • Additional selection criteria
    • Joining tables by JOIN
    • Data insert and update by REPLACE
    • Data insert and update by UPSERT
    • Data insert by INSERT
    • Data update by UPDATE
    • Deleting data
    • Adding and deleting columns
    • Deleting a table
  • Maintenance
    • Backups
  • Diagnostics
    • System views
  • Questions and answers
    • General questions
    • Errors
    • YQL
    • All questions on the same page
  • Public materials
  1. YQL reference guide
  2. Built-in functions
  3. For structures

Functions for structures

  • ExpandStruct
  • AddMember
  • RemoveMember
  • ForceRemoveMember
  • CombineMembers
  • FlattenMembers

ExpandStruct

Adding one or more new fields to the structure.

If the field set contains duplicate values, an error is returned.

Arguments:

  • The first argument passes the source structure to be expanded.
  • All the other arguments must be named, each argument adds a new field and the argument's name is used as the field's name (as in AsStruct).

Examples

$struct = AsStruct(1 AS a);
SELECT
  ExpandStruct(
    $struct,
    2 AS b,
    "3" AS c
  ) AS abc;

AddMember

Adding one new field to the structure. If you need to add multiple fields, better use ExpandStruct.

If the field set contains duplicate values, an error is returned.

Arguments:

  1. Source structure.
  2. Name of the new field.
  3. Value of the new field.

Examples

$struct = AsStruct(1 AS a);
SELECT
  AddMember(
    $struct,
    "b",
    2
  ) AS ab;

RemoveMember

Removing a field from the structure.

If the entered field hasn't existed, an error is returned.

Arguments:

  1. Source structure.
  2. Field name.

Examples

$struct = AsStruct(1 AS a, 2 AS b);
SELECT
  RemoveMember(
    $struct,
    "b"
  ) AS a;

ForceRemoveMember

Removing a field from the structure.

If the entered field hasn't existed, unlike RemoveMember, the error is not returned.

Arguments:

  1. Source structure.
  2. Field name.

Examples

$struct = AsStruct(1 AS a, 2 AS b);
SELECT
  ForceRemoveMember(
    $struct,
    "c"
  ) AS ab;

CombineMembers

Combining the fields from multiple new structures into another new structure.

If the resulting field set contains duplicate values, an error is returned.

Arguments:

  1. Two or more structures.

Examples

$struct1 = AsStruct(1 AS a, 2 AS b);
$struct2 = AsStruct(3 AS c);
SELECT
  CombineMembers(
    $struct1,
    $struct2
  ) AS abc;

FlattenMembers

Combining the fields from multiple new structures into another new structure with prefix support.

If the resulting field set contains duplicate values, an error is returned.

Arguments:

  1. Two or more tuples of two elements: prefix and structure.

Examples

$struct1 = AsStruct(1 AS a, 2 AS b);
$struct2 = AsStruct(3 AS c);
SELECT
  FlattenMembers(
    AsTuple("foo", $struct1), -- fooa, foob
    AsTuple("bar", $struct2)  -- barc
  ) AS abc;
In this article:
  • ExpandStruct
  • AddMember
  • RemoveMember
  • ForceRemoveMember
  • CombineMembers
  • FlattenMembers
Language
Careers
Privacy policy
Terms of use
© 2021 Yandex.Cloud LLC