如何通过自带的元数据,知道表中列是否为生成列

Viewed 20

场景:表中有一列为生成列(generated column),由于在写入数据的时候,对于生成列不能显式写入,需要在写入过程将该类型列找到并在写入语句中去掉
问题:通过自带的语句或者系统表,均无法从查询得到的结果中知道列是否为生成列

--复现过程
--创建database以及表
create database demo_test;
use demo_test;
CREATE TABLE `test_table` (
    `uid` tinyint NULL,
    `age` tinyint NULL,
    `age_plus1` tinyint as (age+1) null,
    `age_plus2` tinyint GENERATED ALWAYS as (age+1) null
)
ENGINE = OLAP DUPLICATE KEY(`uid`)
DISTRIBUTED BY HASH(`uid`) BUCKETS 1;

--写入数据
insert into test_table 
(uid,age)
values
(1, 11);

--通过show column查看列
show full columns from test_table;


--通过元数据查看
select TABLE_CATALOG,TABLE_SCHEMA, TABLE_NAME,COLUMN_NAME,ORDINAL_POSITION,EXTRA
from information_schema.columns
where 1=1 
and TABLE_SCHEMA='demo_test'
and TABLE_NAME='test_table';

--执行语句查看数据
select *
from test_table

表格数据如下
image.png

执行show column结果如下
image.png

查看information_schema.columns结果如下
image.png

但是从文档中看到extra字段应该是会带有列是否为生成列的信息,文档链接如下:
https://doris.apache.org/zh-CN/docs/3.0/admin-manual/system-tables/information_schema/columns?_highlight=generated#%E8%A1%A8%E4%BF%A1%E6%81%AF

1 Answers