Save Table As

Save a copy of an existing table as a new table.

Syntax

save table <source table reference> as
  [temporary | temp] table { <target table spec> | <target table name> }
  [in schema <target schema reference>]
  [with data source <data source reference>]
  [with partitions <partition count> | with max partitions <max partition count>]
  [partition by "<partition columns>"]
  [with replace | with replace with delete]

Parameters

source table reference

String. The name of the source table to save a copy of, optionally qualified by schema name.

target table spec

JSON. A specification for saving the new table. Note that fields are not used and persistence mapping is optional when using this command.

target table name

String. The name of the table to save the copy as.

target schema reference

String. The name of the schema to save the table in. Defaults to the current schema.

data source reference

String. The name of the data source to save the result with. Defaults to the default data source for the repository.

partition count

Integer. The exact number of partitions to save the resulting table with. Specifying this parameter will cause Magpie to shuffle the input data and repartition it into exactly this many partitions. This can be a computationally expensive operation. By default, Magpie specifies a maximum number of partitions for the save, as described below.

max partition count

Integer. The maximum number of partitions to save the resulting table with. If the source table contains more than this number of partitions, those partitions will be coalesced into no more than the number of partitions requested. Both partition count and max partition count cannot be specified at the same time. Defaults to the number of cores available in the Magpie cluster.

partition columns

String. A comma-separated list of column names to partition the resulting table by. Default is unpartitioned.

with replace [with delete]

None. If present and a table already exists with the same name as the target table, this command will drop the existing table and replace it with this new table. If with delete is also present, the underlying data for the existing table will be deleted. If a table does not already exist, this option has no effect. By default, an error will be thrown if a table exists with the same name as the target table.

Was this article helpful?
0 out of 0 found this helpful