Skip to content

Conversation

@feiniaofeiafei
Copy link
Contributor

@feiniaofeiafei feiniaofeiafei commented Jun 4, 2024

related code in apache/doris#35284

@luzhijing
Copy link
Contributor

Please add En docs

@luzhijing
Copy link
Contributor

Waiting for apache/doris#35284 merged.

morrySnow pushed a commit to apache/doris that referenced this pull request Jun 25, 2024
This pr has added support for generated columns. Values of a generated
column are computed from an expression included in the column
definition. Here is an example:

mysql> CREATE TABLE products (
product_id INT,
price DECIMAL(10,2),
quantity INT,
total_value DECIMAL(10,2) GENERATED ALWAYS AS (price * quantity)
) DISTRIBUTED BY HASH(product_id) PROPERTIES ("replication_num" = "1");

mysql> insert into products values(1, 10.00, 10, default);
mysql> insert into products(product_id, price, quantity) values(1, 20.00, 10);
mysql> select * from products;
+------------+-------+----------+-------------+
| product_id | price | quantity | total_value |
+------------+-------+----------+-------------+
|          1 | 10.00 |       10 |      100.00 |
|          1 | 20.00 |       10 |      200.00 |
+------------+-------+----------+-------------+

related docs in apache/doris-website#715

---------

Co-authored-by: feiniaofeiafei <moailing@selectdb.com>
dataroaring pushed a commit to apache/doris that referenced this pull request Jun 26, 2024
This pr has added support for generated columns. Values of a generated
column are computed from an expression included in the column
definition. Here is an example:

mysql> CREATE TABLE products (
product_id INT,
price DECIMAL(10,2),
quantity INT,
total_value DECIMAL(10,2) GENERATED ALWAYS AS (price * quantity)
) DISTRIBUTED BY HASH(product_id) PROPERTIES ("replication_num" = "1");

mysql> insert into products values(1, 10.00, 10, default);
mysql> insert into products(product_id, price, quantity) values(1, 20.00, 10);
mysql> select * from products;
+------------+-------+----------+-------------+
| product_id | price | quantity | total_value |
+------------+-------+----------+-------------+
|          1 | 10.00 |       10 |      100.00 |
|          1 | 20.00 |       10 |      200.00 |
+------------+-------+----------+-------------+

related docs in apache/doris-website#715

---------

Co-authored-by: feiniaofeiafei <moailing@selectdb.com>


## ALTER TABLE和生成列
生成列暂时不支持ADD COLUMN, MODIFY COLUMN。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里有点儿简略。可能会被误会为有生成列的表,都不能添加列和修改列

@feiniaofeiafei feiniaofeiafei changed the title [docs](ddl) add zh-CN docs for generated column [docs](ddl) add docs for generated column Jul 9, 2024
Copy link
Contributor

@luzhijing luzhijing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luzhijing luzhijing merged commit f0fdc62 into apache:master Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants