[Yandex Cloud documentation](../../index.md) > [Tutorials](../index.md) > [Data analysis and visualization](index.md) > DataLens > Service analytics > Visualizing YTsaurus CHYT data

# Visualizing data from CHYT



This section explains how to connect CHYT using a public clique as a data source for DataLens.

## Getting started {#before-you-begin}

To use a YTsaurus table as a data source, select the CHYT clique you will be working with.

{% note info %}

A clique is a virtual cluster in CHYT. It is represented by an operation and has an ID (`operation_id`) or alias (`alias`). There are public and private cliques.

{% endnote %}


When working with CHYT, you can use the public `*ch_public` clique.

## Prepare a data table on YTsaurus {#prepare-table}

Before creating a connector in CHYT, prepare your table on YTsaurus:

- The table must be static. [Learn more about static tables in YTsaurus](https://ytsaurus.tech/docs/ru/user-guide/storage/static-tables).

- The table must be schematized. DataLens queries the table and gets its schema to create a dataset. [Learn more about schemas in YTsaurus](https://ytsaurus.tech/docs/ru/user-guide/storage/static-schema).

{% note tip %}

What we recommend:

* Sorting tables by the main fields used for filtering, e.g., by fields containing dates.
* Enabling the [columnar chunk storage format](https://ytsaurus.tech/docs/ru/user-guide/storage/chunks#columns) using the `optimize_for = scan` attribute. Thus DataLens will process the table faster.

{% endnote %}

## Create a chart {#create-chart}


To create a chart in DataLens, you need to create a connection and dataset over it.

#### Create a connection {#create-connection}

To work with CHYT, create a **CHYT** connection.

 To create a YTsaurus CHYT connection:
 
 1. Open the page for [creating a new connection](https://datalens.ru/connections/new).
 1. Under **Databases**, select the **YTsaurus CHYT** connection.
 
 
 1. Configure the connection as follows:
 
    * **Host name**: Specify the YTsaurus proxy server address.
    * **Port**: Specify the CHYT connection port.
    * **Clique alias**: Specify the alias of a running clique. By default, the `*ch_public` public clique is used.
    * **YTsaurus token**: Manually set the OAuth token to use with YTsaurus. For more information, see [this YTsaurus guide](https://ytsaurus.tech/docs/en/user-guide/storage/auth).
    * **Cache TTL in seconds**: Specify the cache TTL or leave the default value. The recommended value is 300 seconds (5 minutes).
 
    * **Raw SQL level**: Enables you to use an ad-hoc SQL query to [generate a dataset](../../datalens/dataset/settings.md#sql-request-in-datatset). This option is disabled by default. When enabling it, you will need to select the raw SQL level:
    
       * **Allow subqueries in datasets**: Describe dataset sources using [SQL queries](../../datalens/dataset/settings.md#sql-request-in-datatset).
       * **Allow subqueries in datasets and source parameterization**: Describe dataset sources using SQL queries and use [source parameterization](../../datalens/dataset/settings.md#parametrization).
       * **Allow subqueries in datasets, source parameterization, and QL charts**: Describe dataset sources using SQL queries, use source parameterization, and [create QL charts](../../datalens/concepts/chart/ql-charts.md).
 
    * **HTTPS**. Enable the secure connection option if your server supports HTTPS.
 
    ![image](../../_assets/datalens/operations/connection/connection-ytsaurus.png)
 
 
 1. Optionally, test the connection by clicking **Check connection**.
 1. Click **Create connection**.
 
 
 1. Select a [workbook](../../datalens/workbooks-collections/index.md) to save your connection to or create a new one. If using legacy folder navigation, select a folder to save the connection to. Click **Create**.
 
 
 1. Enter a name for the connection and click **Create**.
 
 
 
 ## Additional settings {#additional-settings}
 
 You can limit data export from charts by enabling the **Disable data export** option under **Advanced connection settings**. Thus, for charts based on the respective connection, the export data option will not be available in their ![icon](../../_assets/console-icons/ellipsis.svg) menu. However, you will still be able to copy chart data and take screenshots.
 
You can go straight to creating a dataset from the connection creation interface. To do this, in the top-right corner, click **Create dataset**.

#### Create a dataset {#create-dataset}

After creating a connection, you can create a dataset over it.

1. In the left-hand navigation menu, click ![icon-datasets](../../_assets/console-icons/circles-intersection.svg) and then click **Create dataset** in the top-right corner.
1. In the window that opens, in the **Connections** section, click **+ Add**. Select the **CHYT** connection you created earlier.

1. Select the source indication method:

    - **Table**: One table on YTsaurus. URL from the browser or a full path to a table.

    - **List**: Multiple tables on YTsaurus. URL from the browser or a full path to a table. Use a new row for each table.

    - **Range**: Range of tables on YTsaurus. You can set your own table range using the **Start with** and **Finish at** fields. DataLens will add all the tables specified in the range to the dataset in alphabetical order. If the limit values are left blank, DataLens will use all the tables in the specified folder. You can also set only one limit value.

      {% note info %}

      Let's assume a folder contains twenty tables named `table_1`, `table_2`, `table_3`, ... . If you set the limits as `1` and `5`, DataLens will use only five tables from the folder.

      {% endnote %}

    - **SQL**: Selecting data for a dataset via an SQL query. We recommend copying a query from Query in ClickHouse® syntax and then pasting it into the field. 

      {% note warning %}

      First, process the query you got from Query: delete all semicolon characters (`;`). An entire Query query from DataLens is run as a subquery.

      {% endnote %}

1. Click **Save**. Make sure the data is displayed in the dataset preview.

1. Click **Save** in the top-right corner. Enter a name for the dataset and click **Create**. The dataset will appear in the list of datasets available to you.

On top of the created dataset, you can create various charts and place them on dashboards.

## Frequently asked questions {#questions}


{% cut "Interface error: Access to table was denied" %}

`ERR.DS_API.DB.CHYT.TABLE_ACCESS_DENIED `

The YTsaurus token user has no access to the selected table. Use a different token (from a user who has access to the table) or grant access to the table to the user with a token specified in the connection.
If you do not know who created the connection, create a new one.

{% endcut %}

{% cut "Interface error: Clique not running" %}

`ERR.DS_API.CLIQUE_STOPPED` 

The CHYT clique specified in the current connection is not running. Restart the clique.

{% endcut %}

{% cut "Interface error: Column used in join expression is not a key column" %}

`ERR.DS_API.DB.CHYT.INVALID_SORTED_JOIN`

When you use a CHYT connection, key columns of YTsaurus tables are significant. In multi-table datasets, you can only link tables (by running JOINs) by key columns in these tables. To do this, the following requirements must be met:
* All the columns used to join two tables must form a part of the key for both of them.
* The keys of both tables must begin with exactly those columns.
* The columns must be listed in the same order in the keys of both tables.

To work around this issue, recreate the source tables and specify the keys that will meet the above requirements.

{% endcut %}


{% cut "Interface error: YTsaurus table has no schema. Only schematized tables are supported" %}

`ERR.DS_API.DB.CHYT.TABLE_HAS_NO_SCHEMA`

Your YTsaurus table has no schema. You cannot use such tables in DataLens. Recreate the table with a schema (specify the data types).

{% endcut %}


{% cut "Interface error: Requested database column does not exist" %}

For more information, see [here](../../datalens/troubleshooting/errors/ERR-DS_API-DB-COLUMN_DOES_NOT_EXIST.md).

{% endcut %}

_ClickHouse® is a registered trademark of [ClickHouse, Inc](https://clickhouse.com)._