본문으로 바로가기
본문으로 바로가기

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 (Nullable(String)) — 캐시된 스키마입니다.
  • number_of_rows (Nullable(UInt64)) — 지정된 포맷에서 해당 파일에 포함된 행 수입니다. 데이터 파일에서의 단순한 count() 결과를 캐시하고, 스키마 추론 중 메타데이터에서 얻은 행 수를 캐시하는 데 사용됩니다.
  • schema_inference_mode (Nullable(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.jsonluser_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))

다음 내용도 참고하십시오