JSONCompactColumns 형식

JSONCompactColumns 형식

JSONCompactColumns 형식은 모든 데이터를 단일 JSON 배열로 표현해요. JSONColumns 형식처럼 각 필드의 내용을 배열로 제공하며, 데이터가 컬럼 중심으로 회전된 형태입니다. JSONCompactColumns 출력 형식은 모든 데이터를 메모리에 버퍼링해 단일 블록으로 출력하므로 메모리 소비가 높아질 수 있어요.

출처: 문서

본문

Input Output Alias

설명 (Description)

이 형식에서는 모든 데이터가 단일 JSON Array로 표현됩니다. JSONCompactColumns 출력 형식은 모든 데이터를 메모리에 버퍼링해 단일 블록으로 출력하므로 메모리 소비가 높아질 수 있습니다.

사용 예시 (Example usage)

데이터 삽입 (Inserting data)

football.json이라는 이름의 JSON 파일에 다음 데이터가 있다고 가정해 볼게요:

[
    ["2022-04-30", "2022-04-30", "2022-04-30", "2022-05-02", "2022-05-02", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07"],
    [2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021],
    ["Sutton United", "Swindon Town", "Tranmere Rovers", "Port Vale", "Salford City", "Barrow", "Bradford City", "Bristol Rovers", "Exeter City", "Harrogate Town A.F.C.", "Hartlepool United", "Leyton Orient", "Mansfield Town", "Newport County", "Oldham Athletic", "Stevenage Borough", "Walsall"],
    ["Bradford City", "Barrow", "Oldham Athletic", "Newport County", "Mansfield Town", "Northampton Town", "Carlisle United", "Scunthorpe United", "Port Vale", "Sutton United", "Colchester United", "Tranmere Rovers", "Forest Green Rovers", "Rochdale", "Crawley Town", "Salford City", "Swindon Town"],
    [1, 2, 2, 1, 2, 1, 2, 7, 0, 0, 0, 0, 2, 0, 3, 4, 0],
    [4, 1, 0, 2, 2, 3, 0, 0, 1, 2, 2, 1, 2, 2, 3, 2, 3]
]

데이터를 삽입합니다:

INSERT INTO football FROM INFILE 'football.json' FORMAT JSONCompactColumns;

데이터 읽기 (Reading data)

JSONCompactColumns 형식을 사용하여 데이터를 읽습니다:

SELECT *
FROM football
FORMAT JSONCompactColumns

출력은 JSON 형식이 됩니다:

[
    ["2022-04-30", "2022-04-30", "2022-04-30", "2022-05-02", "2022-05-02", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07", "2022-05-07"],
    [2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021, 2021],
    ["Sutton United", "Swindon Town", "Tranmere Rovers", "Port Vale", "Salford City", "Barrow", "Bradford City", "Bristol Rovers", "Exeter City", "Harrogate Town A.F.C.", "Hartlepool United", "Leyton Orient", "Mansfield Town", "Newport County", "Oldham Athletic", "Stevenage Borough", "Walsall"],
    ["Bradford City", "Barrow", "Oldham Athletic", "Newport County", "Mansfield Town", "Northampton Town", "Carlisle United", "Scunthorpe United", "Port Vale", "Sutton United", "Colchester United", "Tranmere Rovers", "Forest Green Rovers", "Rochdale", "Crawley Town", "Salford City", "Swindon Town"],
    [1, 2, 2, 1, 2, 1, 2, 7, 0, 0, 0, 0, 2, 0, 3, 4, 0],
    [4, 1, 0, 2, 2, 3, 0, 0, 1, 2, 2, 1, 2, 2, 3, 2, 3]
]

블록에 없는 컬럼은 기본값으로 채워집니다(여기서 input_format_defaults_for_omitted_fields 설정을 사용할 수 있어요).

형식 설정 (Format settings)

더 알아보기 (Learn more)