Skip to content

Commit 6b134a5

Browse files
committed
Update 01-virtual-column.md
1 parent 12d1100 commit 6b134a5

File tree

1 file changed

+48
-21
lines changed

1 file changed

+48
-21
lines changed

docs/en/guides/55-performance/01-virtual-column.md

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,34 @@ CREATE VIRTUAL COLUMN (
3434
val ['pricings'] [0] ['type'] -- Extract the 'type' field from the first pricing in the 'pricings' array.
3535
) FOR test;
3636

37-
-- Insert a sample record into the 'test' table with Variant data.
37+
-- Insert sample records into the 'test' table with Variant data.
3838
INSERT INTO
3939
test
4040
VALUES
4141
(
4242
1,
4343
'{"id":1,"name":"databend","tags":["powerful","fast"],"pricings":[{"type":"Standard","price":"Pay as you go"},{"type":"Enterprise","price":"Custom"}]}'
44+
),
45+
(
46+
2,
47+
'{"id":2,"name":"databricks","tags":["scalable","flexible"],"pricings":[{"type":"Free","price":"Trial"},{"type":"Premium","price":"Subscription"}]}'
48+
),
49+
(
50+
3,
51+
'{"id":3,"name":"snowflake","tags":["cloud-native","secure"],"pricings":[{"type":"Basic","price":"Pay per second"},{"type":"Enterprise","price":"Annual"}]}'
52+
),
53+
(
54+
4,
55+
'{"id":4,"name":"redshift","tags":["reliable","scalable"],"pricings":[{"type":"On-Demand","price":"Pay per usage"},{"type":"Reserved","price":"1 year contract"}]}'
56+
),
57+
(
58+
5,
59+
'{"id":5,"name":"bigquery","tags":["innovative","cost-efficient"],"pricings":[{"type":"Flat Rate","price":"Monthly"},{"type":"Flex","price":"Per query"}]}'
4460
);
4561

62+
-- Refresh the virtual columns
63+
REFRESH VIRTUAL COLUMN FOR test;
64+
4665
-- Explain the query execution plan for selecting specific fields from the table.
4766
EXPLAIN
4867
SELECT
@@ -53,16 +72,20 @@ FROM
5372
test;
5473

5574
-[ EXPLAIN ]-----------------------------------
56-
TableScan
57-
├── table: default.default.test
58-
├── output columns: [val['name'] (#2), val['tags'][0] (#3), val['pricings'][0]['type'] (#4)]
59-
├── read rows: 1
60-
├── read bytes: 203
61-
├── partitions total: 1
62-
├── partitions scanned: 1
63-
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1, bloom pruning: 0 to 0>]
64-
├── push downs: [filters: [], limit: NONE, virtual_columns: [val['name'], val['pricings'][0]['type'], val['tags'][0]]]
65-
└── estimated rows: 1.00
75+
Exchange
76+
├── output columns: [test.val['name'] (#2), test.val['tags'][0] (#3), test.val['pricings'][0]['type'] (#4)]
77+
├── exchange type: Merge
78+
└── TableScan
79+
├── table: default.book_db.test
80+
├── output columns: [val['name'] (#2), val['tags'][0] (#3), val['pricings'][0]['type'] (#4)]
81+
├── read rows: 5
82+
├── read size: < 1 KiB
83+
├── partitions total: 1
84+
├── partitions scanned: 1
85+
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1>]
86+
├── push downs: [filters: [], limit: NONE]
87+
├── virtual columns: [val['name'], val['pricings'][0]['type'], val['tags'][0]]
88+
└── estimated rows: 5.00
6689

6790
-- Explain the query execution plan for selecting only the 'name' field from the table.
6891
EXPLAIN
@@ -72,16 +95,20 @@ FROM
7295
test;
7396

7497
-[ EXPLAIN ]-----------------------------------
75-
TableScan
76-
├── table: default.default.test
77-
├── output columns: [val['name'] (#2)]
78-
├── read rows: 1
79-
├── read bytes: 203
80-
├── partitions total: 1
81-
├── partitions scanned: 1
82-
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1, bloom pruning: 0 to 0>]
83-
├── push downs: [filters: [], limit: NONE, virtual_columns: [val['name']]]
84-
└── estimated rows: 1.00
98+
Exchange
99+
├── output columns: [test.val['name'] (#2)]
100+
├── exchange type: Merge
101+
└── TableScan
102+
├── table: default.book_db.test
103+
├── output columns: [val['name'] (#2)]
104+
├── read rows: 5
105+
├── read size: < 1 KiB
106+
├── partitions total: 1
107+
├── partitions scanned: 1
108+
├── pruning stats: [segments: <range pruning: 1 to 1>, blocks: <range pruning: 1 to 1>]
109+
├── push downs: [filters: [], limit: NONE]
110+
├── virtual columns: [val['name']]
111+
└── estimated rows: 5.00
85112

86113
-- Display all the virtual columns defined in the system.
87114
SHOW VIRTUAL COLUMNS;

0 commit comments

Comments
 (0)