MATERIALIZE_FLEXTABLE_COLUMNS

使用 COMPUTE_FLEXTABLE_KEYSCOMPUTE_FLEXTABLE_KEYS_AND_BUILD_VIEW 实体化执行计算的 flextable_keys 表中作为 key_names 列出的虚拟列。

这是元函数。您必须在顶级 SELECT 语句中调用元函数。

行为类型

易变

语法

MATERIALIZE_FLEXTABLE_COLUMNS ('[[database.]schema.]flex-table' [, n-columns [, keys-table-name] ])

实参

[database.]schema

数据库和架构。默认架构为 public。如果指定一个数据库,它必须是当前数据库。

flex-table
具有需要实体化的列的 flex 表的名称。函数:
  • 跳过已实体化的任何列

  • 忽略所有空键

n-列
要实体化的列数,最多为 9800。函数尝试实体化键表中的列数,跳过所有已经实体化的列。按频率降序排列实体化结果。如果未指定,则默认为最多 50 列。
keys-table-name
要从中实体化列的键的名称。函数:
  • 实体化键表中的 n-columns

  • 跳过已实体化的任何列

  • 按频率降序排列实体化结果

示例

以下示例显示了如何调用 MATERIALIZE_FLEXTABLE_COLUMNS 实体化列。首先,将 tweets 样本文件 (tweets_10000.json) 载入 flex 表 twitter_r。加载数据并计算样本 Flex 表的键以后,调用 MATERIALIZE_FLEXTABLE_COLUMNS,实体化前四列:

=> COPY twitter_r FROM '/home/release/KData/tweets_10000.json' parser fjsonparser();
 Rows Loaded
-------------
       10000
(1 row)

=> SELECT compute_flextable_keys ('twitter_r');
              compute_flextable_keys
---------------------------------------------------
 Please see public.twitter_r_keys for updated keys
(1 row)

=> SELECT MATERIALIZE_FLEXTABLE_COLUMNS('twitter_r', 4);
    MATERIALIZE_FLEXTABLE_COLUMNS
-------------------------------------------------------------------------------
 The following columns were added to the table public.twitter_r:
        contributors
        entities.hashtags
        entities.urls
For more details, run the following query:
SELECT * FROM v_catalog.materialize_flextable_columns_results WHERE table_schema = 'public' and table_name = 'twitter_r';

(1 row)

例子的最后一条消息推荐查询 MATERIALIZE_FLEXTABLE_COLUMNS_RESULTS 系统表,查看列实体化的结果,如下所示:

=> SELECT * FROM v_catalog.materialize_flextable_columns_results WHERE table_schema = 'public' and table_name = 'twitter_r';
table_id           | table_schema | table_name |      creation_time           |     key_name      | status |    message
-------------------+--------------+------------+------------------------------+-------------------+--------+---------------------
 45035996273733172 | public       | twitter_r  | 2013-11-20 17:00:27.945484-05| contributors      | ADDED  | Added successfully
 45035996273733172 | public       | twitter_r  | 2013-11-20 17:00:27.94551-05 | entities.hashtags | ADDED  | Added successfully
 45035996273733172 | public       | twitter_r  | 2013-11-20 17:00:27.945519-05| entities.urls     | ADDED  | Added successfully
 45035996273733172 | public       | twitter_r  | 2013-11-20 17:00:27.945532-05| created_at        | EXISTS | Column of same name already
(4 rows)

另请参阅