Skip to content

Commit d0cc9f1

Browse files
authored
update (#158)
1 parent 0d0eb2d commit d0cc9f1

File tree

4 files changed

+111
-4
lines changed

4 files changed

+111
-4
lines changed

changelog/product-lifecycle.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Below is a list of all features in the public preview phase:
2222

2323
| Feature name | Start version |
2424
| :-- | :-- |
25+
| [Ingest data from MySQL table](/integrations/sources/mysql-table)| 2.2 |
2526
| [EXPLAIN FORMAT JSON](/sql/commands/sql-explain#explain-options)| 2.2 |
2627
| [Ingest data from Postgres table](/integrations/sources/postgresql-table) | 2.1 |
2728
| [Ingest data from webhook](/integrations/sources/webhook) | 2.1 |

ingestion/overview.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ The statement will create a streaming job that continuously ingests data from th
7474
4. **Stronger consistency guarantee**: When using a table with connectors, all downstream jobs will be guaranteed to have a consistent view of the data persisted in the table; while for source, different jobs may see inconsistent results due to different ingestion speed or data retention in the external system.
7575
5. **Greater flexibility**: Like regular tables, you can use DML statements like [INSERT](/sql/commands/sql-insert), [UPDATE](/sql/commands/sql-update) and [DELETE](/sql/commands/sql-delete) to insert or modify data in tables with connectors, and use [CREATE SINK INTO TABLE](/sql/commands/sql-create-sink-into) to merge other data streams into the table.
7676

77-
### PostgreSQL table
77+
### Table-valued function
7878

79-
RisingWave supports using the table-valued function `postgres_query` to directly query PostgreSQL databases. This function connects to a specified PostgreSQL instance, executes the provided SQL query, and returns the results as a table in RisingWave.
79+
RisingWave supports using the table-valued function (TVF) `postgres_query` or `mysql_query` to directly query PostgreSQL or MySQL databases. This function connects to a specified instance, executes the provided SQL query, and returns the results as a table in RisingWave.
8080

81-
To use it, specify connection details (such as hostname, port, username, password, database name) and the desired SQL query. This makes it easier to integrate PostgreSQL data directly into RisingWave workflows without needing additional data transfer steps. For more information, see [Ingest data from Postgres tables](/integrations/sources/postgresql-table).
81+
To use it, specify connection details (such as hostname, port, username, password, database name) and the desired SQL query. This makes it easier to integrate databases directly into RisingWave workflows without needing additional data transfer steps. For more information, see [Ingest data from Postgres tables](/integrations/sources/postgresql-table) and [Ingest data from MySQL tables](/integrations/sources/mysql-table).
8282

8383
## DML on tables
8484

integrations/sources/mysql-table.mdx

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
title: "Ingest data from MySQL table"
3+
description: "Describes how to ingest data from MySQL table to RisingWave using table-valued function."
4+
sidebarTitle: MySQL table
5+
---
6+
7+
RisingWave allows you to query MySQL tables directly with the `mysql_query` table-valued function (TVF). It offers a simpler alternative to Change Data Capture (CDC) when working with MySQL data in RisingWave.
8+
9+
Unlike CDC, which continuously syncs data changes, this function lets you fetch data directly from MySQL when needed. Therefore, this approach is ideal for static or infrequently updated data, as it's more resource-efficient than maintaining a constant CDC connection.
10+
11+
<Note>
12+
**PUBLIC PREVIEW**
13+
14+
This feature is currently in public preview, meaning it is nearing the final product but may not yet be fully stable. If you encounter any issues or have feedback, please reach out to us via our [Slack channel](https://www.risingwave.com/slack). Your input is valuable in helping us improve this feature. For more details, see our [Public Preview Feature List](/changelog/product-lifecycle#features-in-the-public-preview-stage).
15+
</Note>
16+
17+
<Note>
18+
Added in version 2.2.
19+
</Note>
20+
21+
## Syntax
22+
23+
Define `mysql_query` as follows:
24+
25+
```sql
26+
mysql_query(
27+
hostname varchar, -- Database hostname
28+
port varchar, -- Database port
29+
username varchar, -- Authentication username
30+
password varchar, -- Authentication password
31+
database_name varchar, -- Target database name
32+
query varchar -- SQL query to execute
33+
)
34+
```
35+
36+
## Data type mapping
37+
38+
The following table shows how MySQL data types are mapped to RisingWave data types:
39+
40+
| MySQL Type | RisingWave Type |
41+
|:-----------|:----------------|
42+
| `bit(1)` | `boolean` |
43+
| `bit(>1)` | `bytea` |
44+
| `bool`/`boolean` | `smallint` |
45+
| `tinyint` | `smallint` |
46+
| `smallint` | `smallint` |
47+
| `mediumint` | `int` |
48+
| `int` | `int` |
49+
| `bigint` | `bigint` |
50+
| `float` | `float32` |
51+
| `double` | `float64` |
52+
| `decimal` | `decimal` |
53+
| `numeric` | `decimal` |
54+
| `year` | `int` |
55+
| `date` | `date` |
56+
| `time` | `time` |
57+
| `datetime` | `timestamp` |
58+
| `timestamp` | `timestamptz` |
59+
| `varchar` | `varchar` |
60+
| `char` | `varchar` |
61+
| `json` | `jsonb` |
62+
| `blob` | `bytea` |
63+
| `tinyblob` | `bytea` |
64+
| `mediumblob` | `bytea` |
65+
| `longblob` | `bytea` |
66+
| `array` | *unsupported* |
67+
| `enum` | *unsupported* |
68+
| `set` | *unsupported* |
69+
| `geometry` | *unsupported* |
70+
| `null` | *unsupported* |
71+
72+
## Example
73+
74+
1. In your MySQL database, create a table and populate it with sample data of various data types.
75+
76+
```sql
77+
CREATE TABLE test (
78+
id bigint primary key, v0 bit, v1 bool, v2 tinyint(1),
79+
v3 tinyint(2), v4 smallint, v5 mediumint, v6 integer,
80+
v7 bigint, v8 float, v9 double, v10 numeric(4, 2),
81+
v11 decimal(4, 2), v12 char(255), v13 varchar(255),
82+
v14 bit(10), v15 tinyblob, v16 blob, v17 mediumblob,
83+
v18 longblob, v19 date, v20 time, v21 timestamp,
84+
v22 json
85+
);
86+
87+
INSERT INTO test SELECT
88+
1 as id, true as v0, true as v1, 2 as v2, 3 as v3, 4 as v4, 5 as v5,
89+
6 as v6, 7 as v7, 1.08 as v8, 1.09 as v9, 1.10 as v10, 1.11 as v11,
90+
'char' as v12, 'varchar' as v13, b'1010' as v14, x'16' as v15, x'17' as v16,
91+
x'18' as v17, x'19' as v18, '2021-01-01' as v19, '12:34:56' as v20,
92+
'2021-01-01 12:34:56' as v21, JSON_OBJECT('key1', 1, 'key2', 'abc');
93+
```
94+
95+
2. In RisingWave, use `postgres_query` function to perform the query.
96+
97+
```sql
98+
SELECT *
99+
FROM mysql_query('$MYSQL_HOST', '$MYSQL_TCP_PORT', '$RISEDEV_MYSQL_USER', '$MYSQL_PWD', 'tvf', 'select * from test;');
100+
----RESULT
101+
1 t 1 2 3 4 5 6 7 1.08 1.09 1.10 1.11 char varchar \x000a \x16 \x17 \x18 \x19 2021-01-01 12:34:56 2021-01-01 12:34:56+00:00 {"key1": 1, "key2": "abc"}
102+
```

integrations/sources/postgresql-table.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ sidebarTitle: PostgreSQL table
66

77
RisingWave allows you to query PostgreSQL tables directly with the `postgres_query` table-valued function (TVF). It offers a simpler alternative to Change Data Capture (CDC) when working with PostgreSQL data in RisingWave.
88

9-
Unlike CDC, which continuously syncs data changes, this function lets you fetch data directly from PostgreSQL when needed. Therefore, this approach is ideal static or infrequently updated data, as it's more resource-efficient than maintaining a constant CDC connection.
9+
Unlike CDC, which continuously syncs data changes, this function lets you fetch data directly from PostgreSQL when needed. Therefore, this approach is ideal for static or infrequently updated data, as it's more resource-efficient than maintaining a constant CDC connection.
1010

1111
<Note>
1212
**PUBLIC PREVIEW**
1313

1414
This feature is currently in public preview, meaning it is nearing the final product but may not yet be fully stable. If you encounter any issues or have feedback, please reach out to us via our [Slack channel](https://www.risingwave.com/slack). Your input is valuable in helping us improve this feature. For more details, see our [Public Preview Feature List](/changelog/product-lifecycle#features-in-the-public-preview-stage).
1515
</Note>
1616

17+
<Note>
18+
Added in version 2.1.
19+
</Note>
20+
1721
## Syntax
1822

1923
Define `postgres_query` as follows:

0 commit comments

Comments
 (0)