# How to Create a Data Source for Data Streamed from Kafka

### 1. Grant DataPancake access to the database, schema, and table

Open a new Snowflake SQL file and run the necessary statements for the database, schema, and table which contain the Kafka data. For example:

<pre class="language-sql"><code class="lang-sql"><strong>GRANT USAGE ON DATABASE DB_NAME TO APPLICATION DATAPANCAKE;
</strong>GRANT USAGE ON SCHEMA DB_NAME.SCHEMA_NAME TO APPLICATION DATAPANCAKE;
GRANT REFERENCES, SELECT ON TABLE DB_NAME.SCHEMA_NAME.TABLE_NAME TO APPLICATION DATAPANCAKE;
</code></pre>

{% hint style="info" %}
**Imported databases (e.g. Confluent)**: If your Kafka data lives in an imported database, run:

`GRANT IMPORTED PRIVILEGES ON DATABASE DB_NAME TO APPLICATION DATAPANCAKE;`

Use `GRANT IMPORTED PRIVILEGES` on the imported database instead of granting individual privileges on database, schema, and table.

Need help? Read more about [Snowflake shared databases](https://docs.snowflake.com/en/user-guide/data-sharing-gs)
{% endhint %}

<figure><img src="/files/paWl12VmytIQ9sFvUdgM" alt=""><figcaption></figcaption></figure>

### 2. In DataPancake, navigate to the Data Sources page

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/d0b65499-fa95-429a-bd15-f890cea3490a/ascreenshot.jpeg?tl_px=0,0\&br_px=1376,769\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=75,198)

### 3. Enter a name for the new data source

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/0fcceceb-00af-43c4-b4e2-6bc4dee3cafa/ascreenshot.jpeg?tl_px=0,52\&br_px=1376,821\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=410,277)

### 4. Select the data source type

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/f87f3bd3-69d1-4690-bd59-931fbb8dfaff/ascreenshot.jpeg?tl_px=0,210\&br_px=1376,979\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=441,277)

### 5. (Optional) Enter data source tags

These are simply used for filtering / searching. For example: `dev`, `prod`, `api`, `csv`

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/79fcc624-d149-48fb-9891-5e05eabb4b85/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=409,340)

### 6. Select "Kafka" for the source stream platform

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/445b6744-8645-4a35-b208-fc306a3a8d96/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=394,399)

### 7. (Optional) Deduplicate Messages

If checked, two dynamic tables will be produced for the root attributes in the semi-structured data source. The first dynamic table will be used to flatten the root attributes. The second dynamic table will be used to filter the flattened rows using a window function (configured in the next step) to produce the most recent message for each primary key.

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/b0063838-fb18-419f-b3bf-facbe5eca25f/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=318,388)

### 8. Enter the Deduplication SQL Expression&#x20;

{% hint style="info" %}

### Required only if "Deduplicate Messages" is toggled on

{% endhint %}

The sql expression used to deduplicate the source stream messages based on a primary key and sort order to produce the most recent message. This value is required if the SQL Code Generation feature is selected and the Deduplicate Messages option is enabled.

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/33aa1e90-7157-451f-94fa-94be41a4bd68/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=419,454)

### 9. Select the Object Type

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/39b0d764-a6e9-4863-9291-fc74fdb8f3ff/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=448,377)

### 10. Select the Column Data Type

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/932f1f67-7dd3-43f5-ab16-4157953ee436/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=485,345)

### 12. Select the Format Type

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/aa177a2b-31c9-4430-8a10-6f4bcec24882/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=423,451)

### 13. Select the Database

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/7cbeefd2-a485-41ac-b81b-bc34794b2759/ascreenshot.jpeg?tl_px=164,223\&br_px=1541,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=662,311)

### 14. Select the Schema

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/d16937b4-9e9f-4d13-861b-695ef239d518/ascreenshot.jpeg?tl_px=164,223\&br_px=1541,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=745,349)

### 15. Select the Object Name

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/873f334d-cb10-4184-8dc1-2d52a1b8156f/ascreenshot.jpeg?tl_px=164,223\&br_px=1541,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=734,419)

### 16. Enter the Column Name

This column name can be a sql expression that refers to a specific path of the semi-structured data source. See the example below.

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/6e0517a2-343d-4c1b-b808-ef5334e5f9f5/ascreenshot.jpeg?tl_px=164,161\&br_px=1541,930\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=909,276)

### 17. Click 'Enable Feature Selection'

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/7fd2c224-9f3a-4f74-9333-6a4cf1b14067/ascreenshot.jpeg?tl_px=164,223\&br_px=1541,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=705,440)

### 18. Select "SQL Code Generation"

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/8a592d21-3302-4d0e-a934-ae0bb9f26560/ascreenshot.jpeg?tl_px=164,223\&br_px=1541,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=751,303)

### 19. Select the Output Object Type

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/cb3722b0-abef-41aa-843e-825d0fcf2b49/ascreenshot.jpeg?tl_px=0,54\&br_px=1376,823\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=522,277)

### 20. Configure additional settings as needed

[How to configure materialization object & dynamic table settings](/guides/how-to-guides-ui/creating-and-configuring-data-sources/how-to-configure-output-object-and-dynamic-table-settings.md)\
[How to configure the secure view](/guides/how-to-guides-ui/creating-and-configuring-data-sources/how-to-configure-the-secure-semantic-view-layer.md)\
How to configure schema consolidation (WIP)\
[How to configure schema filters](/guides/how-to-guides-ui/creating-and-configuring-data-sources/how-to-configure-schema-filters.md)

### 21. Save the data source

The save button is near the bottom of the page.

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/7e3bedb1-7015-4942-a840-3434d1b8db90/ascreenshot.jpeg?tl_px=0,223\&br_px=1376,993\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=402,387)

### 22. Verify the save completed successfully.

![](https://ajeuwbhvhr.cloudimg.io/https://colony-recorder.s3.amazonaws.com/files/2025-06-11/2c210d97-9275-4a9d-98d2-e005a7182d3b/ascreenshot.jpeg?tl_px=164,0\&br_px=1541,769\&force_format=jpeg\&q=100\&width=1120.0\&wat=1\&wat_opacity=1\&wat_gravity=northwest\&wat_url=https://colony-recorder.s3.amazonaws.com/images/watermarks/FB923C_standard.png\&wat_pad=928,104)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.datapancake.com/guides/how-to-guides-ui/creating-and-configuring-data-sources/how-to-create-a-data-source-for-data-streamed-from-kafka.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
