Skip to content

Commit 58e34c8

Browse files
YDB FQ: docs for Microsoft SQL Server as an external data source (#7786)
Co-authored-by: Ivan Blinkov <ivan@ydb.tech>
1 parent 3b70619 commit 58e34c8

File tree

14 files changed

+168
-22
lines changed

14 files changed

+168
-22
lines changed
Loading

ydb/docs/en/core/concepts/federated_query/architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Users can deploy [one of the ready-made connectors](../../deploy/manual/connecto
3232
|--------|---------|
3333
| [ClickHouse](https://clickhouse.com/) | Via connector [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3434
| [Greenplum](https://www.greenplum.org/) | Via connector [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
35+
| [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) | Via connector [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3536
| [MySQL](https://www.mysql.com/) | Via connector [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3637
| [PostgreSQL](https://www.postgresql.org/) | Via connector [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3738
| [S3](https://aws.amazon.com/ru/s3/) | Built into `ydbd` |

ydb/docs/en/core/concepts/federated_query/greenplum.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ When working with Greenplum clusters, there are a number of limitations:
4545

4646
## Supported data types
4747

48-
In the Greenplum database, the optionality of column values (whether a column can contain `NULL` values) is not part of the data type system. The `NOT NULL` constraint for each column is implemented as the `attnotnull` attribute in the system catalog [pg_attribute](https://www.postgresql.org/docs/current/catalog-pg-attribute.html), i.e., at the metadata level of the table. Therefore, all basic Greenplum types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system, they should be mapped to [optional](https://ydb.tech/docs/ru/yql/reference/types/optional) types.
48+
In the Greenplum database, the optionality of column values (whether a column can contain `NULL` values) is not part of the data type system. The `NOT NULL` constraint for each column is implemented as the `attnotnull` attribute in the system catalog [pg_attribute](https://www.postgresql.org/docs/current/catalog-pg-attribute.html), i.e., at the metadata level of the table. Therefore, all basic Greenplum types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system, they should be mapped to [optional](../../yql/reference/types/optional.md) types.
4949

5050
Below is a correspondence table between Greenplum and {{ ydb-short-name }} types. All other data types, except those listed, are not supported.
5151

@@ -73,4 +73,4 @@ Below is a correspondence table between Greenplum and {{ ydb-short-name }} types
7373
| `bytea` | `Optional<String>` ||
7474
| `character` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html), string padded with spaces to the required length. |
7575
| `character varying` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html). |
76-
| `text` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html). |
76+
| `text` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html). |
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Working with Microsoft SQL Server databases
2+
3+
This section provides basic information about working with an external [Microsoft SQL Server](https://learn.microsoft.com/en-us/sql/?view=sql-server-ver16) databases.
4+
5+
To work with an external Microsoft SQL Server database, you need to follow these steps:
6+
1. Create a [secret](../datamodel/secrets.md) containing the password for connecting to the database.
7+
```sql
8+
CREATE OBJECT ms_sql_server_datasource_user_password (TYPE SECRET) WITH (value = "<password>");
9+
```
10+
1. Create an [external data source](../datamodel/external_data_source.md) that describes a specific Microsoft SQL Server database. The `LOCATION` parameter contains the network address of the Microsoft SQL Server instance to connect to. The `DATABASE_NAME` specifies the database name (for example, `master`). The `LOGIN` and `PASSWORD_SECRET_NAME` parameters are used for authentication to the external database. You can enable encryption for connections to the external database using the `USE_TLS="TRUE"` parameter.
11+
```sql
12+
CREATE EXTERNAL DATA SOURCE ms_sql_server_datasource WITH (
13+
SOURCE_TYPE="Microsoft SQL Server",
14+
LOCATION="<host>:<port>",
15+
DATABASE_NAME="<database>",
16+
AUTH_METHOD="BASIC",
17+
LOGIN="user",
18+
PASSWORD_SECRET_NAME="ms_sql_server_datasource_user_password",
19+
USE_TLS="TRUE"
20+
);
21+
```
22+
1. {% include [!](_includes/connector_deployment.md) %}
23+
1. [Execute a query](#query) to the database.
24+
25+
## Query syntax { #query }
26+
The following SQL query format is used to work with Microsoft SQL Server:
27+
28+
```sql
29+
SELECT * FROM ms_sql_server_datasource.<table_name>
30+
```
31+
32+
where:
33+
- `ms_sql_server_datasource` - the external data source identifier;
34+
- `<table_name>` - the table name within the external data source.
35+
36+
## Limitations
37+
38+
When working with Microsoft SQL Server clusters, there are a number of limitations:
39+
40+
1. {% include [!](_includes/supported_requests.md) %}
41+
2. {% include [!](_includes/datetime_limits.md) %}
42+
3. {% include [!](_includes/predicate_pushdown.md) %}
43+
44+
## Supported data types
45+
46+
In the Microsoft SQL Server database, the optionality of column values (whether the column can contain `NULL` values or not) is not a part of the data type system. The `NOT NULL` constraint for any column of any table is stored within the `IS_NULLABLE` column the [INFORMATION_SCHEMA.COLUMNS](https://learn.microsoft.com/en-us/sql/relational-databases/system-information-schema-views/columns-transact-sql?view=sql-server-ver16) system table, i.e., at the table metadata level. Therefore, all basic Microsoft SQL Server types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system, they should be mapped to [optional](../../yql/reference/types/optional.md).
47+
48+
Below is a correspondence table between Microsoft SQL Server types and {{ ydb-short-name }} types. All other data types, except those listed, are not supported.
49+
50+
| Microsoft SQL Server Data Type | {{ ydb-full-name }} Data Type | Notes |
51+
|---|----|------|
52+
|`bit`|`Optional<Bool>`||
53+
|`tinyint`|`Optional<Int8>`||
54+
|`smallint`|`Optional<Int16>`||
55+
|`int`|`Optional<Int32>`||
56+
|`bigint`|`Optional<Int64>`||
57+
|`real`|`Optional<Float>`||
58+
|`float`|`Optional<Double>`||
59+
|`date`|`Optional<Date>`|Valid date range from 1970-01-01 to 2105-12-31. Values outside this range return `NULL`.|
60+
|`smalldatetime`|`Optional<Datetime>`|Valid time range from 1970-01-01 00:00:00 to 2105-12-31 23:59:59. Values outside this range return `NULL`.|
61+
|`datetime`|`Optional<Timestamp>`|Valid time range from 1970-01-01 00:00:00 to 2105-12-31 23:59:59. Values outside this range return `NULL`.|
62+
|`datetime2`|`Optional<Timestamp>`|Valid time range from 1970-01-01 00:00:00 to 2105-12-31 23:59:59. Values outside this range return `NULL`.|
63+
|`binary`|`Optional<String>`||
64+
|`varbinary`|`Optional<String>`||
65+
|`image`|`Optional<String>`||
66+
|`char`|`Optional<Utf8>`||
67+
|`varchar`|`Optional<Utf8>`||
68+
|`text`|`Optional<Utf8>`||
69+
|`nchar`|`Optional<Utf8>`||
70+
|`nvarchar`|`Optional<Utf8>`||
71+
|`ntext`|`Optional<Utf8>`||

ydb/docs/en/core/concepts/federated_query/mysql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ When working with MySQL clusters, there are a number of limitations:
4343
4444
## Supported data types
4545
46-
In the MySQL database, the optionality of column values (whether the column can contain `NULL` values or not) is not a part of the data type system. The `NOT NULL` constraint for any column of any table is stored within the `IS_NULLABLE` column the [INFORMATION_SCHEMA.COLUMNS](https://dev.mysql.com/doc/refman/8.4/en/information-schema-columns-table.html) system table, i.e., at the table metadata level. Therefore, all basic MySQL types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system they should be mapped to [optional](https://ydb.tech/docs/ru/yql/reference/types/optional).
46+
In the MySQL database, the optionality of column values (whether the column can contain `NULL` values or not) is not a part of the data type system. The `NOT NULL` constraint for any column of any table is stored within the `IS_NULLABLE` column the [INFORMATION_SCHEMA.COLUMNS](https://dev.mysql.com/doc/refman/8.4/en/information-schema-columns-table.html) system table, i.e., at the table metadata level. Therefore, all basic MySQL types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system they should be mapped to [optional](../../yql/reference/types/optional.md).
4747
4848
Below is a correspondence table between MySQL types and {{ ydb-short-name }} types. All other data types, except those listed, are not supported.
4949

ydb/docs/en/core/concepts/federated_query/postgresql.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ When working with PostgreSQL clusters, there are a number of limitations:
4545

4646
## Supported data types
4747

48-
In the PostgreSQL database, the optionality of column values (whether a column can contain `NULL` values) is not part of the data type system. The `NOT NULL` constraint for each column is implemented as the `attnotnull` attribute in the system catalog [pg_attribute](https://www.postgresql.org/docs/current/catalog-pg-attribute.html), i.e., at the metadata level of the table. Therefore, all basic PostgreSQL types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system, they should be mapped to [optional](https://ydb.tech/docs/ru/yql/reference/types/optional) types.
48+
In the PostgreSQL database, the optionality of column values (whether a column can contain `NULL` values) is not part of the data type system. The `NOT NULL` constraint for each column is implemented as the `attnotnull` attribute in the system catalog [pg_attribute](https://www.postgresql.org/docs/current/catalog-pg-attribute.html), i.e., at the metadata level of the table. Therefore, all basic PostgreSQL types can contain `NULL` values by default, and in the {{ ydb-full-name }} type system, they should be mapped to [optional](../../yql/reference/types/optional.md) types.
4949

5050
Below is a correspondence table between PostgreSQL and {{ ydb-short-name }} types. All other data types, except those listed, are not supported.
5151

@@ -73,4 +73,4 @@ Below is a correspondence table between PostgreSQL and {{ ydb-short-name }} type
7373
| `character` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html), string padded with spaces to the required length. |
7474
| `character varying` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html). |
7575
| `text` | `Optional<Utf8>` | [Default collation rules](https://www.postgresql.org/docs/current/collation.html). |
76-
|`json`|`Optional<Json>`||
76+
|`json`|`Optional<Json>`||
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
items:
2-
- { name: Overview, href: index.md }
3-
- { name: Architecture, href: architecture.md }
4-
- { name: Working with ClickHouse databases, href: clickhouse.md }
5-
- { name: Working with Greenplum databases, href: greenplum.md }
6-
- { name: Working with MySQL databases, href: mysql.md }
7-
- { name: Working with PostgreSQL databases, href: postgresql.md }
8-
- { name: Working with YDB databases, href: ydb.md }
2+
- { name: Overview, href: index.md }
3+
- { name: Architecture, href: architecture.md }
4+
- { name: Working with ClickHouse databases, href: clickhouse.md }
5+
- { name: Working with Greenplum databases, href: greenplum.md }
6+
- { name: Working with Microsoft SQL Server databases, href: ms_sql_server.md }
7+
- { name: Working with MySQL databases, href: mysql.md }
8+
- { name: Working with PostgreSQL databases, href: postgresql.md }
9+
- { name: Working with YDB databases, href: ydb.md }
910
- name: Working with S3 buckets
1011
include: { path: s3/toc_i.yaml, mode: link }
Loading

ydb/docs/ru/core/concepts/federated_query/architecture.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| -------- | --------- |
3434
| [ClickHouse](https://clickhouse.com/) | Через коннектор [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3535
| [Greenplum](https://greenplum.org/) | Через коннектор [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
36+
| [Microsoft SQL Server](https://learn.microsoft.com/ru-ru/sql/?view=sql-server-ver16) | Через коннектор [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3637
| [MySQL](https://www.mysql.org/) | Через коннектор [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3738
| [PostgreSQL](https://www.postgresql.org/) | Через коннектор [fq-connector-go](../../deploy/manual/connector.md#fq-connector-go) |
3839
| [S3](https://aws.amazon.com/ru/s3/) | Встроенная в `ydbd` |

ydb/docs/ru/core/concepts/federated_query/greenplum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SELECT * FROM greenplum_datasource.<table_name>
4444

4545
## Поддерживаемые типы данных
4646

47-
В базе данных Greenplum признак опциональности значений колонки (разрешено или запрещено колонке содержать значения `NULL`) не является частью системы типов данных. Ограничение (constraint) `NOT NULL` для каждой колонки реализуется в виде атрибута `attnotnull` в системном каталоге [pg_attribute](https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/ref_guide-system_catalogs-pg_attribute.html), то есть на уровне метаданных таблицы. Следовательно, все базовые типы Greenplum по умолчанию могут содержать значения `NULL`, и в системе типов {{ ydb-full-name }} они должны отображаться в [опциональные](https://ydb.tech/docs/ru/yql/reference/types/optional) типы.
47+
В базе данных Greenplum признак опциональности значений колонки (разрешено или запрещено колонке содержать значения `NULL`) не является частью системы типов данных. Ограничение (constraint) `NOT NULL` для каждой колонки реализуется в виде атрибута `attnotnull` в системном каталоге [pg_attribute](https://docs.vmware.com/en/VMware-Greenplum/6/greenplum-database/ref_guide-system_catalogs-pg_attribute.html), то есть на уровне метаданных таблицы. Следовательно, все базовые типы Greenplum по умолчанию могут содержать значения `NULL`, и в системе типов {{ ydb-full-name }} они должны отображаться в [опциональные](../../yql/reference/types/optional.md) типы.
4848

4949
Ниже приведена таблица соответствия типов Greenplum и {{ ydb-short-name }}. Все остальные типы данных, за исключением перечисленных, не поддерживаются.
5050

0 commit comments

Comments
 (0)