メインコンテンツまでスキップ
メインコンテンツまでスキップ

ORC

InputOutputAlias

説明

Apache ORCは、Hadoopエコシステムで広く使用されている列指向ストレージ形式です。

データ型のマッピング

以下の表は、サポートされているORCデータ型と、それに対応するClickHouseのdata typesINSERTおよびSELECTクエリで比較したものです。

ORCデータ型 (INSERT)ClickHouseデータ型ORCデータ型 (SELECT)
BooleanUInt8Boolean
TinyintInt8/UInt8/Enum8Tinyint
SmallintInt16/UInt16/Enum16Smallint
IntInt32/UInt32Int
BigintInt64/UInt32Bigint
FloatFloat32Float
DoubleFloat64Double
DecimalDecimalDecimal
DateDate32Date
TimestampDateTime64Timestamp
String, Char, Varchar, BinaryStringBinary
ListArrayList
StructTupleStruct
MapMapMap
IntIPv4Int
BinaryIPv6Binary
BinaryInt128/UInt128/Int256/UInt256Binary
BinaryDecimal256Binary
  • その他のタイプはサポートされていません。
  • 配列はネスト可能で、引数としてNullable型の値を持つことができます。TupleおよびMap型もネスト可能です。
  • ClickHouseテーブルのカラムのデータ型は、対応するORCデータフィールドと一致する必要はありません。データを挿入する際、ClickHouseは上の表に従ってデータ型を解釈し、次にキャストしてClickHouseテーブルカラムに設定されたデータ型にデータを変換します。

使用例

データの挿入

以下のデータを持つORCファイルを使用し、football.orcとして名前を付けます:

    ┌───────date─┬─season─┬─home_team─────────────┬─away_team───────────┬─home_team_goals─┬─away_team_goals─┐
 1. │ 2022-04-30 │   2021 │ Sutton United         │ Bradford City       │               1 │               4 │
 2. │ 2022-04-30 │   2021 │ Swindon Town          │ Barrow              │               2 │               1 │
 3. │ 2022-04-30 │   2021 │ Tranmere Rovers       │ Oldham Athletic     │               2 │               0 │
 4. │ 2022-05-02 │   2021 │ Port Vale             │ Newport County      │               1 │               2 │
 5. │ 2022-05-02 │   2021 │ Salford City          │ Mansfield Town      │               2 │               2 │
 6. │ 2022-05-07 │   2021 │ Barrow                │ Northampton Town    │               1 │               3 │
 7. │ 2022-05-07 │   2021 │ Bradford City         │ Carlisle United     │               2 │               0 │
 8. │ 2022-05-07 │   2021 │ Bristol Rovers        │ Scunthorpe United   │               7 │               0 │
 9. │ 2022-05-07 │   2021 │ Exeter City           │ Port Vale           │               0 │               1 │
10. │ 2022-05-07 │   2021 │ Harrogate Town A.F.C. │ Sutton United       │               0 │               2 │
11. │ 2022-05-07 │   2021 │ Hartlepool United     │ Colchester United   │               0 │               2 │
12. │ 2022-05-07 │   2021 │ Leyton Orient         │ Tranmere Rovers     │               0 │               1 │
13. │ 2022-05-07 │   2021 │ Mansfield Town        │ Forest Green Rovers │               2 │               2 │
14. │ 2022-05-07 │   2021 │ Newport County        │ Rochdale            │               0 │               2 │
15. │ 2022-05-07 │   2021 │ Oldham Athletic       │ Crawley Town        │               3 │               3 │
16. │ 2022-05-07 │   2021 │ Stevenage Borough     │ Salford City        │               4 │               2 │
17. │ 2022-05-07 │   2021 │ Walsall               │ Swindon Town        │               0 │               3 │
    └────────────┴────────┴───────────────────────┴─────────────────────┴─────────────────┴─────────────────┘

データを挿入します:

INSERT INTO football FROM INFILE 'football.orc' FORMAT ORC;

データの読み取り

ORC形式を使用してデータを読み取ります:

SELECT *
FROM football
INTO OUTFILE 'football.orc'
FORMAT ORC
ヒント

ORCはバイナリ形式であり、端末で人間が読み取れる形では表示されません。INTO OUTFILEを使用してORCファイルを出力してください。

フォーマット設定

設定説明デフォルト
output_format_arrow_string_as_string文字列カラムに対してバイナリの代わりにArrow String型を使用します。false
output_format_orc_compression_method出力ORC形式で使用される圧縮方法。デフォルト値none
input_format_arrow_case_insensitive_column_matchingArrowカラムとClickHouseカラムを照合する際に大文字と小文字を無視します。false
input_format_arrow_allow_missing_columnsArrowデータを読み取る際に欠落したカラムを許可します。false
input_format_arrow_skip_columns_with_unsupported_types_in_schema_inferenceArrow形式のスキーマ推論においてサポートされていない型のカラムをスキップできます。false

Hadoopとのデータ交換には、HDFSテーブルエンジンを使用できます。