Version:

Create Union

Merges data from one or more tables with comparable data types into a new table.

The following merges are supported:

UNION (DISTINCT/ALL) - For data set union details and examples, see Union. For limitations, see Union Limitations and Cautions.

INTERSECT (DISTINCT/ALL) - For data set intersection details and examples, see Intersect. For limitations, see Intersect Limitations.

EXCEPT (DISTINCT/ALL) - For data set subtraction details and examples, see Except. For limitations, see Except Limitations.

MERGE VIEWS - For a given set of filtered views on a single table, creates a single filtered view containing all of the unique records across all of the given filtered data sets.

Non-charN 'string' and 'bytes' column types cannot be merged, nor can columns marked as store-only.

Input Parameter Description

Name Type Description
table_name string Name of the table to be created. Has the same naming restrictions as tables.
table_names array of strings The list of table names to merge. Must contain the names of one or more existing tables.
input_column_names array of arrays of strings The list of columns from each of the corresponding input tables.
output_column_names array of strings The list of names of the columns to be stored in the output table.
options map of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
collection_name Name of a collection which is to contain the output table. If the collection provided is non-existent, the collection will be automatically created. If empty, the output table will be a top-level table. The default value is ''.
materialize_on_gpu

If true, then the columns of the output table will be cached on the GPU. The supported values are:

  • true
  • false
mode

If merge_views, then this operation will merge the provided views. All input parameter table_names must be views from the same underlying base table.

Supported Values Description
union_all Retains all rows from the specified tables.
union Retains all unique rows from the specified tables (synonym for union_distinct).
union_distinct Retains all unique rows from the specified tables.
except Retains all unique rows from the first table that do not appear in the second table (only works on 2 tables).
except_all Retains all rows(including duplicates) from the first table that do not appear in the second table (only works on 2 tables).
intersect Retains all unique rows that appear in both of the specified tables (only works on 2 tables).
intersect_all Retains all rows(including duplicates) that appear in both of the specified tables (only works on 2 tables).
merge_views Merge two or more views (or views of views) of the same base data set into a new view. If this mode is selected input parameter input_column_names AND input parameter output_column_names must be empty. The resulting view would match the results of a SQL OR operation, e.g., if filter 1 creates a view using the expression 'x = 20' and filter 2 creates a view using the expression 'x <= 10', then the merge views operation creates a new view using the expression 'x = 20 OR x <= 10'.
chunk_size Indicates the chunk size to be used for this table.
create_indexes Comma-separated list of columns on which to create indexes on the output table. The columns specified must be present in input parameter output_column_names.
ttl Sets the TTL of the table specified in input parameter table_name.
persist

If true, then the table specified in input parameter table_name will be persisted and will not expire unless a ttl is specified. If false, then the table will be an in-memory table and will expire unless a ttl is specified otherwise. The supported values are:

  • true
  • false
view_id view the output table will be a part of. The default value is ''.
force_replicated

If true, then the table specified in input parameter table_name will be replicated even if the source tables are not. The supported values are:

  • true
  • false

Output Parameter Description

Name Type Description
table_name string Value of input parameter table_name.
info map of string to strings Additional information.