跳到主要内容
跳到主要内容

system.schema_inference_cache

在 ClickHouse Cloud 中查询

此系统表中的数据在 ClickHouse Cloud 中的每个节点上本地保存。因此,要获得所有数据的完整视图,需要使用 clusterAllReplicas 函数。有关进一步的详细信息,请参见 这里

包含有关所有缓存文件模式的信息。

列:

  • storage (String) — 存储名称:File, URL, S3 或 HDFS。
  • source (String) — 文件来源。
  • format (String) — 格式名称。
  • additional_format_info (String) - 识别模式所需的附加信息。例如,特定于格式的设置。
  • registration_time (DateTime) — 模式加入缓存时的时间戳。
  • schema (String) - 缓存模式。

示例

假设我们有一个文件 data.jsonl,其内容如下:

{"id" :  1, "age" :  25, "name" :  "Josh", "hobbies" :  ["football", "cooking", "music"]}
{"id" :  2, "age" :  19, "name" :  "Alan", "hobbies" :  ["tennis", "art"]}
{"id" :  3, "age" :  32, "name" :  "Lana", "hobbies" :  ["fitness", "reading", "shopping"]}
{"id" :  4, "age" :  47, "name" :  "Brayan", "hobbies" :  ["movies", "skydiving"]}
提示

data.jsonl 放置在 user_files_path 目录中。您可以通过查看您的 ClickHouse 配置文件来找到此目录。默认值为:

<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>

打开 clickhouse-client 并运行 DESCRIBE 查询:

DESCRIBE file('data.jsonl') SETTINGS input_format_try_infer_integers=0;
┌─name────┬─type────────────────────┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ id      │ Nullable(Float64)       │              │                    │         │                  │                │
│ age     │ Nullable(Float64)       │              │                    │         │                  │                │
│ name    │ Nullable(String)        │              │                    │         │                  │                │
│ hobbies │ Array(Nullable(String)) │              │                    │         │                  │                │
└─────────┴─────────────────────────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘

让我们看看 system.schema_inference_cache 表的内容:

SELECT *
FROM system.schema_inference_cache
FORMAT Vertical
Row 1:
──────
storage:                File
source:                 /home/droscigno/user_files/data.jsonl
format:                 JSONEachRow
additional_format_info: schema_inference_hints=, max_rows_to_read_for_schema_inference=25000, schema_inference_make_columns_nullable=true, try_infer_integers=false, try_infer_dates=true, try_infer_datetimes=true, try_infer_numbers_from_strings=true, read_bools_as_numbers=true, try_infer_objects=false
registration_time:      2022-12-29 17:49:52
schema:                 id Nullable(Float64), age Nullable(Float64), name Nullable(String), hobbies Array(Nullable(String))

另请参见