确定 Snowflake 中的列是否为虚拟列

Rob*_*b D 6 calculated-columns virtual-column snowflake-cloud-data-platform

Snowflake 没有记录其使用 AS 子句的虚拟列功能。我正在进行迁移,需要以编程方式过滤掉虚拟列。

有什么方法可以识别一列是虚拟的吗?该Information Schema.COLLUMNS视图显示虚拟列定义和非虚拟列定义之间没有任何区别。

CMe*_*CMe 1

使用SHOW COLUMNS怎么样?当表达式 字段不为空时,您应该识别它们。

create table foo (id bigint, derived bigint as (id * 10));
insert into foo (id) values (1), (2), (3);

SHOW COLUMNS IN TABLE foo;
SELECT "table_name", "column_name", "expression" FROM table(result_scan(last_query_id()));

| table_name | column_name | expression     |
| ---------- | ----------- | -------------- |
| FOO        | ID          | null           |
| FOO        | DERIVED     | ID*10          |
Run Code Online (Sandbox Code Playgroud)