> For the complete documentation index, see [llms.txt](https://docs.caoanalytics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caoanalytics.com/user-guide/generate-mapping.md).

# Generate Mapping

Use the Generate Mapping screen to create a new mapping from source and target systems.

Use the Generate Mapping screen in the left navigation menu to create a new mapping from source and target systems. This feature is also accessible via the Design tab in the top navigation.

### Navigation

You can access via the Home Screen in the left navigation menu or in drop down menu via the Design tab in the main header.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F16e41c7ad550de617397963a86976a5195066df8.png?generation=1607558963343006&amp;alt=media" alt=""></div>

When on the Generate Mapping page, you can collapse the Choose Connections and Choose Mapping Type menus by clicking on the header of each section.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F8d933c44325276c822a790cb9ef852f8718cbdde.png?generation=1607558963383236&amp;alt=media" alt=""></div>

You can resize the left hand column of the page by hovering the cursor over the line that divides it from the center column.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2Fcfabd756d2a757dcd84d92bab918d784dcf36f9b.png?generation=1607558963175773&amp;alt=media" alt=""></div>

## Choose Connections

To generate a new mapping choose a source and target data store from the two select lists.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F469f88d55a52a28140f30ae0840b8cccfb9038ab.png?generation=1607558964246891&amp;alt=media" alt=""></div>

* To be available as a source or target, an Administrator must add them in the [Manage Connections](/getting-started/manage-connections.md) screen.

## Choose Mapping Type

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F13cef099a4976bf3431c74194f843efec24ba9cc.png?generation=1607558964300374&amp;alt=media" alt=""></div>

Once a source and target is selected, you then choose one of the available Mapping Types below.

* **All Schemas and Tables** allows you generate a mapping of every table in every schema of your source database.   &#x20;
* **Schema(s)** allows you to select one or schemas in the source database, generating mappings for each table in the schema(s) selected.     &#x20;
* **Tables(s)** allows you to select a single schema and then select one or more tables in the schema.
* **Views(s)** allows you to select a single schema and then select one or more views in the schema.
* **Custom Query** provides the ability to craft custom SQL queries as mappings. Custom SQL gives you the ability to build data pipelines with the most advanced series of conditions.

If a selected map(s) already exists, you will receive a warning they will be overwritten if you should choose to continue.

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F1f7522f32a900a14abe0dd2d368de1d08002d3cc.png?generation=1607558963143517\&alt=media)

### All Schemas and Tables

All Schemas and Tables *\*\**&#x61;llows you generate a mapping of every table in every schema of your source database.

### Choose Schema(s)

Use this multi-select list to select schema(s) when you opt to create a mapping for a Schema(s) or Table(s) as noted above. The <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line"> button will remain disabled until all required selections have been made.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F42f33bc6eabf14d5cb39ff58d520412619af6d7f.png?generation=1607558964330461&amp;alt=media" alt=""></div>

Once you click the Generate Mapping, the Generation Results will appear in the center of the page. The results will return the following fields:

* Map Type
* Source Connection
* Source Container
* Source Table
* Target Connection
* Map Name
* Status
* Run Mapping &#x20;

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F0077beac04d8e98ccb7fb3376dcec83c90cebec6.png?generation=1607558963178800\&alt=media)

### Choose Table(s)

Tables(s) allows you to select a single schema and then select one or more tables in the schema. The <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line"> button will remain disabled until all required selections have been made.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F76ac0ed638b0e326cfa83a665ca6cf2f3f94e40a.png?generation=1607558963136826&amp;alt=media" alt=""></div>

### Choose View(s)

After you choose Connections, Mapping Type (Views) and Schema/Table, the Generation Results will be displayed in the center of the page. The <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line"> button will remain disabled until all required selections have been made.

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F784f6cdd54a1a5d6b30299932b93f45d3ba3ecb7.png?generation=1607558964321074&amp;alt=media" alt=""></div>

### Custom Query

Custom Query provides the ability to craft custom SQL queries as mappings. Custom SQL gives you the ability to build data pipelines with the most advanced series of conditions.

* Enter Target Schema Name
* Enter Target Table Name
* Enter SQL Statement

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F2c5c81a48a4204c28758c9791e4026859ad2e043.png?generation=1607558964254769\&alt=media)

After you enter the Target Schema Name, Target Table Name and the custom SQL Statement, the Test SQL<img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2Fbb63c4e9468510a8ca2ff5f2f0d4c254f91c870f.png?generation=1607558963016773&amp;alt=media" alt="" data-size="line">button will appear below the Generate Mapping<img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line">button in the Activities section.

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2Fdfc0c321f227702ccb62628bce8a57af9d17915d.png?generation=1607558964533898\&alt=media)

{% hint style="info" %}
In order for Kodda to generate a sequence (*sometimes referred to as an identity column*) use the Kodda function $sequence()$ in your query. At run time Kodda will generate this column as an identity/sequence column on the target table.&#x20;
{% endhint %}

When you click on the <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F712f5c6af0ea607e09152e54f59b0409670711e5.png?generation=1607558964306269&amp;alt=media" alt="" data-size="line"> Test SQL button, the **Query Result** will display. If your custom SQL is not accurate, you will be presented with an error message.

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F1eb65919a8f9ea8897aa13f78b5da8ffdd4c1fd7.png?generation=1607558963134736\&alt=media)

After the SQL is tested, click on the <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line"> button to complete the mapping of the custom query.

![](https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F9f36e9364507a9297ff9d59442de45c1fda0d3ec.png?generation=1607558963280534\&alt=media)

## Activities

#### Generate Mapping

Generate Mapping creates an auto generated data pipeline from source to target, storing those parameters in the repository. Click the green Generate Mapping button <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line"> and Kodda generates one or more mappings based upon how you set the Mapping Types noted above.

* Be sure to review the Options and [Workflow Options ](/user-guide/design-workflow.md)before you click Generate Mapping

Once you generate your mapping(s), the Generation Results in the center pane of the screen show your mappings with links that you can use to jump directly to the Edit Mapping screen, with the noted mapping open for you to review and/or modify as necessary.

* If you auto-generated a workflow as described in [Workflow Options ](/getting-started/manage-connections.md)[Design Workflow](/user-guide/design-workflow.md) screen.
* Additionally, simply click the respective ![run-button](https://docs.kodda.io/_attach/1.0/507d790fde753b653a436608d8a984f378ad84edb61fd199/Generate-Mapping-image0.gif) icon to run individual mappings from the list one at a time or run the entire auto-generated workflow.

![](https://docs.kodda.io/_attach/1.0/507d790fde753b653a436608d8a984f378ad84edb61fd199/GenMap%2BScreenShot.png)

## Workflow Options

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2Fc1ec14ba3550976bd3120ea99fd467edf739fb3c.png?generation=1607558963031891&amp;alt=media" alt="Click slider to automatically enable or disable generating a workflow."></div>

| Workflow Options      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Generate Workflow** | Before you hit the <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line">button, if you set this Generate Workflow option on, then Kodda automatically creates all the mappings you need and a workflow to run them all. When generation completes, you see this new workflow under all the mappings in the Generation Results on the center console of the screen. This simple option allows you to generate the mapping and workflow all in one step, and then with one more click of the <img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F3be79c07eafda862fd820964bb3fa8d380867e43.png?generation=1607558963394284&amp;alt=media" alt="" data-size="line">button, you can run the entire set of new mappings. If your workflow is large and/or complex enough to warrant additional review, you can always edit the workflow to optimize its auto-generated logic. To edit it, just click the provided link which will migrate you directly to this workflow in the [Design Workflow](/user-guide/design-workflow.md) screen. |
| **Workflow Name**     | When you opt to automatically generate a workflow with the Generate Workflow option described above, enter a name here for the resulting workflow. If a workflow with this name already exists, you are informed of it and forced to provide a unique workflow name.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| **Max Parallel**      | <p>Set the maximum number of parallel mappings allowed in the auto-generated workflow or some basic ability to tune your resulting workflow. For example, if generating mappings for 100 tables, and you select to automatically generate a workflow as noted above, setting this parameter to 20 will create a workflow with 20 parallel streams, each executing 5 mappings in sequence. These parallel streams are randomly generated by Kodda's internal algorithms. You may review and edit the auto-generated workflow if you believe your data pipeline is large and/or complex enough to warrant the time spent optimizing the data ingest process, such as a 2000 table process in which you want some tables to specifically load before others, or other complex use cases.</p><p><em>\*While there is no max, a number between 2-8 is recommended.</em></p>                                                                                                                                                                                                                                                                                                                                                                                                                      |
|                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |

## Advanced Options

<div align="left"><img src="https://1682448182-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MO8vUiMZbKjefXbyOes%2Fsync%2F94808d7485c828410b77d1f42127202cd0ff5332.png?generation=1607558963191757&amp;alt=media" alt="Click sliders to enable or disable advanced options."></div>

| Options                   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Disable Audit Columns** | By default, Kodda automatically includes three standard audit columns of si\_job\_id, si\_create\_date and si\_update\_date on each table mapping it creates, and auto-populates them in the target records when the mapping is run. These columns are very useful in tracing the lineage of your target data. If the user does not want these fields generated in the target data, users can disable their creation by turning it on.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| **Disable Target DDL**    | When Kodda runs a mapping, if the mapped object does not exist in the target database, by default Kodda creates and runs DDL (Data Definition Language) to create the object, then loads the data. Kodda will also add any additional columns that do not yet exist on the target table. Disable this default behavior by turning this option on if you do not want your target table structures to be modified by the mappings generated. Disabling target DDL is useful if you have two databases that may not be fully in-sync and yet you still want to migrate data between them without touching their structure. For instance, if you are replicating data from a production to a test or development database, and you want to move the data only, but not change the structure in your test or development environment. The Detect Target Changes option below is often also useful when disabling this option. |
| **Detect Source Changes** | Kodda can duplicate tables from source to target automatically. Alternatively, turning this option on allows you to enforce that all the mapping(s) generated pick up any source data structure changes when moving data into the target. In effect, this allows you to add columns in your source system that will automatically appear in your mapping at run time. In addition if you drop columns in table(s) in your source system they would no longer be included data extract process.                                                                                                                                                                                                                                                                                                                                                                                                                           |
| **Detect Target Changes** | Set this will option on to ensure that data will only be delivered to columns that are available in the target. When generating a mapping to move data from source to target, if a column exists on the source, Kodda's default presumption is that this column also exists on the target. This option instructs Kodda at run time to ignore columns from the source that do not yet exist in the target table. For example, if a column exists on the source, and the Disable Target DDL option has been enabled, Kodda will not attempt to insert data from this column on the target.                                                                                                                                                                                                                                                                                                                                 |
| **Match Source Name**     | By default Kodda will auto rename schemas, tables and columns with reserved words on the target table postfixed with an "\_". Additionally, Kodda will auto rename columns that exceed the 30 characters in length. Kodda also generates a name for the target schema/database used for the target table based on the source connection and source schema name. Enable this to override this behavior and ensure that the generated mappings are set to deliver data to target objects with the same schema, table and column names found in the source.                                                                                                                                                                                                                                                                                                                                                                 |
