Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions docs/cn/guides/55-performance/01-virtual-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,13 @@ import EEFeature from '@site/src/components/EEFeature';

## 配置

```sql
-- 启用功能(实验性)
SET enable_experimental_virtual_column = 1;

-- 可选:控制自动刷新行为
SET enable_refresh_virtual_column_after_write = 1; -- 默认启用
```
虚拟列自 v1.2.832 起默认启用,无需额外配置。

## 完整示例

演示自动虚拟列创建与性能优势:

```sql
SET enable_experimental_virtual_column=1;

-- 创建表 'test',含整型 id 列和 Variant 类型 val 列
CREATE TABLE test(id int, val variant);

Expand Down Expand Up @@ -168,4 +160,4 @@ SHOW VIRTUAL COLUMNS WHERE table='test';

---

*虚拟列在后台自动工作——只需启用功能,Databend 将优化您的 JSON 查询。*
*虚拟列在后台自动工作——只需启用功能,Databend 将优化您的 JSON 查询。*
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ title: system.virtual_columns

import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="引入或更新于:v1.2.262"/>
<FunctionDescription description="引入或更新于:v1.2.832"/>

包含系统中已创建的虚拟列 (Virtual Column) 的信息。

另请参阅:[SHOW VIRTUAL COLUMNS](../../10-sql-commands/00-ddl/07-virtual-column/show-virtual-columns.md)

```sql
SET enable_experimental_virtual_column=1;
虚拟列自 v1.2.832 起默认启用。

```sql
SELECT * FROM system.virtual_columns;

╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
Expand All @@ -22,4 +22,4 @@ SELECT * FROM system.virtual_columns;
│ default │ test │ val │ 3000000000 │ ['id'] │ UInt64 │
│ default │ test │ val │ 3000000001 │ ['name'] │ String │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ sidebar_position: 3

import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.271"/>
<FunctionDescription description="Introduced or updated: v1.2.832"/>

import EEFeature from '@site/src/components/EEFeature';

<EEFeature featureName='VIRTUAL COLUMN'/>

Databend 中的 `REFRESH VIRTUAL COLUMN` 命令用于显式触发现有表的 virtual column 的创建。虽然 Databend 会自动管理新数据的 virtual column,但在某些特定情况下,需要手动刷新才能充分利用此功能。

虚拟列自 v1.2.832 起默认启用。

## 何时使用 `REFRESH VIRTUAL COLUMN`

- **在启用功能之前已存在的表:** 如果你的表包含在启用 virtual column 功能*之前*(或在升级到具有自动 virtual column 创建的版本之前)创建的 `VARIANT` 数据,则需要刷新 virtual column 以启用查询加速。Databend 不会自动为这些表中已存在的数据创建 virtual column。
- **禁用写入时自动刷新:** 如果在数据摄取期间将 `enable_refresh_virtual_column_after_write` 设置为 `0`(禁用),则 Databend 将*不会*在写入数据时自动创建 virtual column。在这种情况下,如果希望从性能改进中受益,则必须在加载数据后手动刷新 virtual column。

## 语法

Expand All @@ -29,10 +30,6 @@ REFRESH VIRTUAL COLUMN FOR <table>
此示例刷新名为“test”的表的 virtual column:

```sql
SET enable_experimental_virtual_column=1;

SET enable_refresh_virtual_column_after_write=0;

CREATE TABLE test(id int, val variant);

INSERT INTO
Expand All @@ -49,12 +46,12 @@ VALUES

REFRESH VIRTUAL COLUMN FOR test;

SHOW VIRTUAL COLUMNS WHERE table = 'test';
SHOW VIRTUAL COLUMNS WHERE table = 'test' AND database = 'default';
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ database │ table │ source_column │ virtual_column_id │ virtual_column_name │ virtual_column_type │
│ String │ String │ String │ UInt32 │ String │ String │
├──────────┼────────┼───────────────┼───────────────────┼─────────────────────┼─────────────────────┤
│ default │ test │ val │ 3000000000 │ ['id'] │ UInt64 │
│ default │ test │ val │ 3000000001 │ ['name'] │ String │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,29 @@ sidebar_position: 4
---
import FunctionDescription from '@site/src/components/FunctionDescription';

<FunctionDescription description="Introduced or updated: v1.2.271"/>
<FunctionDescription description="Introduced or updated: v1.2.832"/>

import EEFeature from '@site/src/components/EEFeature';

<EEFeature featureName='VIRTUAL COLUMN'/>

显示系统中创建的 virtual column。等效于 `SELECT * FROM system.virtual_columns`。

虚拟列自 v1.2.832 起默认启用。

另请参阅:[system.virtual_columns](../../../00-sql-reference/31-system-tables/system-virtual-columns.md)

## 语法
## 推荐语法

通过最直接的用法查看特定表(或不带条件查看全部):

```sql
SHOW VIRTUAL COLUMNS [ LIKE '<pattern>' | WHERE <expr> ] | [ LIMIT <limit> ]
SHOW VIRTUAL COLUMNS [WHERE table = '<table_name>' AND database = '<database_name>']
```

## 示例

```sql
SET enable_experimental_virtual_column=1;

CREATE TABLE test(id int, val variant);

INSERT INTO
Expand All @@ -39,12 +41,12 @@ VALUES
'{"id":2,"name":"databricks"}'
);

SHOW VIRTUAL COLUMNS WHERE table = 'test';
SHOW VIRTUAL COLUMNS WHERE table = 'test' AND database = 'default';
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
│ database │ table │ source_column │ virtual_column_id │ virtual_column_name │ virtual_column_type │
│ String │ String │ String │ UInt32 │ String │ String │
├──────────┼────────┼───────────────┼───────────────────┼─────────────────────┼─────────────────────┤
│ default │ test │ val │ 3000000000 │ ['id'] │ UInt64 │
│ default │ test │ val │ 3000000001 │ ['name'] │ String │
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ FUSE_VIRTUAL_COLUMN('<database_name>', '<table_name>'[, '<snapshot_id>'])
## 示例

```sql
SET enable_experimental_virtual_column=1;

CREATE TABLE test(id int, val variant);

INSERT INTO
Expand Down Expand Up @@ -47,4 +45,4 @@ SELECT * FROM FUSE_VIRTUAL_COLUMN('default', 'test');
│ │ │ 0a01_v2.parque │ │ │ │ │ │ │ │
│ │ │ t │ │ │ │ │ │ │ │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
```
```
12 changes: 2 additions & 10 deletions docs/en/guides/55-performance/01-virtual-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,13 @@ When querying JSON data, traditional databases must parse the entire JSON struct

## Configuration

```sql
-- Enable the feature (experimental)
SET enable_experimental_virtual_column = 1;

-- Optional: Control auto-refresh behavior
SET enable_refresh_virtual_column_after_write = 1; -- Default: enabled
```
Virtual columns are enabled by default starting from v1.2.832 and require no additional configuration.

## Complete Example

This example demonstrates automatic virtual column creation and performance benefits:

```sql
SET enable_experimental_virtual_column=1;

-- Create a table named 'test' with columns 'id' and 'val' of type Variant.
CREATE TABLE test(id int, val variant);

Expand Down Expand Up @@ -169,4 +161,4 @@ Virtual columns typically provide:

---

*Virtual columns work automatically in the background - simply enable the feature and let Databend optimize your JSON queries.*
*Virtual columns work automatically in the backgroundDatabend optimizes your JSON queries with zero configuration.*
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ Behind the scenes Databend keeps track of which JSON path produced each virtual

With indexing handled behind the scenes, you interact with Variant columns using familiar syntax and functions.

### Inspect Virtual Columns

Use [`SHOW VIRTUAL COLUMNS`](/sql/sql-commands/ddl/virtual-column/show-virtual-columns) to list the automatically generated virtual columns for a table when you want to verify what JSON paths Databend has materialised.

### Access Syntax

Databend understands both Snowflake-style and PostgreSQL-style selectors; whichever style you prefer, the engine routes them through the same key-path parser and reuses the JSON indexes. Continuing with an `orders` example, you can reach nested fields like this:
Expand Down
Loading
Loading