> ## Documentation Index
> Fetch the complete documentation index at: https://docs.maia.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Rewrite Table

export const ComponentMetadata = ({warehouses, unsupportedWarehouses = [], componentType, connectionInputs, connectionOutputs}) => {
  const allWarehouses = [...warehouses.map(w => ({
    name: w,
    supported: true
  })), ...unsupportedWarehouses.map(w => ({
    name: w,
    supported: false
  }))];
  return <div style={{
    background: 'var(--colors-background-light, #f9fafb)',
    border: '1px solid var(--colors-border-default, #e5e7eb)',
    borderRadius: '12px',
    padding: '20px 28px',
    marginBottom: '28px',
    boxShadow: '0 1px 4px rgba(0,0,0,0.10)'
  }}>
      <table style={{
    width: '100%',
    borderCollapse: 'collapse'
  }}>
        <tbody>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle',
    width: '180px'
  }}>Project Availability</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>
              <div style={{
    display: 'flex',
    flexWrap: 'wrap',
    gap: '8px'
  }}>
                {allWarehouses.map((w, i) => <span key={i} style={{
    background: w.supported ? '#dcfce7' : '#fee2e2',
    color: w.supported ? '#15803d' : '#b91c1c',
    border: `1px solid ${w.supported ? '#bbf7d0' : '#fca5a5'}`,
    borderRadius: '9999px',
    padding: '3px 12px',
    fontSize: '0.85rem',
    fontWeight: '500',
    whiteSpace: 'nowrap'
  }}>
                    {w.name} {w.supported ? '✅' : '❌'}
                  </span>)}
              </div>
            </td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Component Type</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{componentType}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    paddingBottom: '14px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Inputs</td>
            <td style={{
    paddingBottom: '14px',
    verticalAlign: 'middle'
  }}>{connectionInputs}</td>
          </tr>
          <tr>
            <td style={{
    fontWeight: '600',
    paddingRight: '32px',
    whiteSpace: 'nowrap',
    verticalAlign: 'middle'
  }}>Connection Outputs</td>
            <td style={{
    verticalAlign: 'middle'
  }}>{connectionOutputs}</td>
          </tr>
        </tbody>
      </table>
    </div>;
};

<ComponentMetadata warehouses={["Snowflake", "Databricks", "Amazon Redshift", "Google BigQuery"]} componentType="Transformation" connectionInputs="One" connectionOutputs="None" />

The **Rewrite Table** transformation component writes the input dataset to a new table in your cloud data warehouse. If a table of the same name already exists, it will be replaced by a new table. Rewrite Table will be the last component in your pipeline, as you write the dataset out after all other processing is complete.

This is equivalent to the SQL **CREATE OR REPLACE TABLE** command.

When using this component, be aware of the following:

* Because the output table is overwritten each time the component is executed, you shouldn't use this component to output permanent data that you don't want to overwrite.
* Runtime errors may occur. For example, if a data value overflows the maximum allowed size of a field.
* The component isn't suitable for incremental updates, as all existing data in the table is deleted during the rewrite.

To write the dataset to a table without replacing the entire target table, use [Table Output](/docs/components/table-output) or [Table Update](/docs/components/table-update) instead.

### Use case

The Rewrite Table component will completely replace the contents of a target table in your data warehouse with new data. Some common use cases for this include:

* Full refresh of dimension tables. When the data in a dimension table changes infrequently or is small enough to reload entirely, use Rewrite Table to replace the entire contents with the latest snapshot.
* Refresh staging tables. You can overwrite a staging table using Rewrite Table before running further transformation pipelines on it.
* Initial load of target tables. Create and populate a new table to give a clean load of initial data.

***

## Properties

<Tabs>
  <Tab title="Snowflake">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[warehouse] | warehouses: [snowflake] --> */}

    <ResponseField name="Warehouse" type="drop-down" required>
      The Snowflake warehouse used to run the queries. The special value `[Environment Default]` uses the warehouse defined in the environment. Read [Overview of Warehouses](https://docs.snowflake.com/en/user-guide/warehouses-overview.html) to learn more.
    </ResponseField>

    {/* <!-- param-start:[database] | warehouses: [snowflake] --> */}

    <ResponseField name="Database" type="drop-down" required>
      The Snowflake database. The special value `[Environment Default]` uses the database defined in the environment. Read [Databases, Tables and Views - Overview](https://docs.snowflake.com/en/guides-overview-db) to learn more.
    </ResponseField>

    {/* <!-- param-start:[schema] | warehouses: [snowflake] --> */}

    <ResponseField name="Schema" type="drop-down" required>
      The Snowflake schema. The special value `[Environment Default]` uses the schema defined in the environment. Read [Database, Schema, and Share DDL](https://docs.snowflake.com/en/sql-reference/ddl-database.html) to learn more.
    </ResponseField>

    {/* <!-- param-start:[targetTable] | warehouses: [snowflake] --> */}

    <ResponseField name="Target Table" type="string" required>
      A name for the new table.

      This component uses the **CREATE OR REPLACE** clause. When using the **REPLACE** clause, it also applies the **COPY GRANTS** clause. When you clone or create a new object (such as a table, view, schema, or database) from an existing one, the new object doesn't automatically inherit the original's grants (privileges). However, with the **COPY GRANTS** clause, you can seamlessly transfer object-level privileges from the source object to the new one. This helps maintain consistent access control and simplifies permission management when cloning or recreating objects. For more information, read [Snowflake COPY GRANTS](https://docs.snowflake.com/en/sql-reference/sql/create-table#label-create-table-copy-grants).
    </ResponseField>

    {/* <!-- param-start:[orderBy] | warehouses: [snowflake] --> */}

    <ResponseField name="Order By" type="column editor">
      Select the columns to order by. Set the corresponding column to be ordered ascending (default) or descending.
    </ResponseField>
  </Tab>

  <Tab title="Databricks">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    <ResponseField name="Catalog" type="drop-down" required>
      Select a [Databricks Unity Catalog](https://docs.databricks.com/en/data-governance/unity-catalog/index.html). The special value `[Environment Default]` uses the catalog defined in the environment. Selecting a catalog will determine which databases are available in the next parameter.
    </ResponseField>

    <ResponseField name="Schema (Database)" type="drop-down" required>
      The Databricks schema. The special value `[Environment Default]` uses the schema defined in the environment. Read [Create and manage schemas](https://docs.databricks.com/en/data-governance/unity-catalog/create-schemas.html) to learn more.
    </ResponseField>

    {/* <!-- param-start:[targetTable] | warehouses: [databricks] --> */}

    <ResponseField name="Table" type="string" required>
      A name for the new table.
    </ResponseField>

    <ResponseField name="Partition Keys" type="dual listbox">
      Select any input columns to be used as partition keys.
    </ResponseField>

    <ResponseField name="Table Properties" type="column editor">
      * **Key:** A metadata property within the table. These are expressed as key=value pairs.
      * **Value:** The value of the corresponding row's key.
    </ResponseField>

    <ResponseField name="Comment" type="string">
      A descriptive comment of the view.
    </ResponseField>
  </Tab>

  <Tab title="Amazon Redshift">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[schema] | warehouses: [redshift] --> */}

    <ResponseField name="Schema" type="drop-down" required>
      Select the table schema. The special value `[Environment Default]` uses the schema defined in the environment. For more information on using multiple schemas, read [Schemas](https://docs.aws.amazon.com/redshift/latest/dg/r_Schemas_and_tables.html).
    </ResponseField>

    {/* <!-- param-start:[targetTable] | warehouses: [redshift] --> */}

    <ResponseField name="Target Table" type="string" required>
      A name for the new table.
    </ResponseField>

    <ResponseField name="Table Sort Key" type="column editor">
      Specify the columns from the input that should be set as the table's sort-key.

      Sort-keys are critical to good performance. Read the [Amazon Redshift documentation](https://docs.aws.amazon.com/redshift/latest/dg/t_Sorting_data.html) for more information.
    </ResponseField>

    <ResponseField name="Table Distribution Style" type="drop-down" required>
      Select how the data in the table will be distributed. Choose from - ALL, EVEN, or KEY. For more information, read [Distribution styles](https://docs.aws.amazon.com/redshift/latest/dg/c_choosing_dist_sort.html).
    </ResponseField>

    <ResponseField name="Table Distribution Key" type="drop-down" required>
      This is only displayed if the Table Distribution Style is set to Key. It is the column used to determine which cluster node the row is stored on.
    </ResponseField>
  </Tab>

  <Tab title="Google BigQuery">
    <ResponseField name="Name" type="string" required>
      A human-readable name for the component.
    </ResponseField>

    {/* <!-- param-start:[gcpProjectId] | warehouses: [bigquery] --> */}

    <ResponseField name="GCP Project ID" type="drop-down" required>
      The Google Cloud project that owns the BigQuery dataset. The special value `[Environment Default]` uses the Google Cloud project defined in the environment. For more information, read [Creating projects](https://docs.cloud.google.com/resource-manager/docs/creating-managing-projects).
    </ResponseField>

    {/* <!-- param-start:[dataset] | warehouses: [bigquery] --> */}

    <ResponseField name="Dataset" type="drop-down" required>
      The Google BigQuery dataset where the table will be created or updated. The special value `[Environment Default]` uses the dataset defined in the environment.
    </ResponseField>

    {/* <!-- param-start:[targetTable] | warehouses: [bigquery] --> */}

    <ResponseField name="Target Table" type="string" required>
      A name for the new table.
    </ResponseField>
  </Tab>
</Tabs>
