> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-parallel-read-in-order-multi-part.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentação do formato ORC

# ORC

| Entrada | Saída | Alias |
| - | - | - |
| ✔ | ✔ | |

<div id="description">
  ## Descrição
</div>

[Apache ORC](https://orc.apache.org/) é um formato de armazenamento colunar amplamente utilizado no ecossistema [Hadoop](https://hadoop.apache.org/).

<div id="data-types-matching-orc">
  ## Correspondência de tipos de dados
</div>

A tabela abaixo compara os tipos de dados ORC suportados e os correspondentes [tipos de dados](/pt-BR/reference/data-types/index) do ClickHouse em consultas `INSERT` e `SELECT`.

| Tipo de dado ORC (`INSERT`) | Tipo de dado ClickHouse | Tipo de dado ORC (`SELECT`) |
| - | - | - |
| `Boolean` | [Bool](/pt-BR/reference/data-types/boolean) | `Boolean` |
| `Tinyint` | [Int8/UInt8](/pt-BR/reference/data-types/int-uint)/[Enum8](/pt-BR/reference/data-types/enum) | `Tinyint` |
| `Smallint` | [Int16/UInt16](/pt-BR/reference/data-types/int-uint)/[Enum16](/pt-BR/reference/data-types/enum) | `Smallint` |
| `Int` | [Int32/UInt32](/pt-BR/reference/data-types/int-uint) | `Int` |
| `Bigint` | [Int64/UInt64](/pt-BR/reference/data-types/int-uint) | `Bigint` |
| `Float` | [Float32](/pt-BR/reference/data-types/float) | `Float` |
| `Double` | [Float64](/pt-BR/reference/data-types/float) | `Double` |
| `Decimal` | [Decimal](/pt-BR/reference/data-types/decimal) | `Decimal` |
| `Date` | [Date32](/pt-BR/reference/data-types/date32) | `Date` |
| `Timestamp` | [DateTime64](/pt-BR/reference/data-types/datetime64) | `Timestamp` |
| `String`, `Varchar`, `Binary` | [String](/pt-BR/reference/data-types/string) | `String` |
| `Char` | [FixedString](/pt-BR/reference/data-types/fixedstring) | `String` |
| `List` | [Array](/pt-BR/reference/data-types/array) | `List` |
| `Struct` | [Tuple](/pt-BR/reference/data-types/tuple) | `Struct` |
| `Map` | [Map](/pt-BR/reference/data-types/map) | `Map` |
| `Int` | [IPv4](/pt-BR/reference/data-types/int-uint) | `Int` |
| `Binary` | [IPv6](/pt-BR/reference/data-types/ipv6) | `Binary` |
| `Binary` | [Int128/UInt128/Int256/UInt256](/pt-BR/reference/data-types/int-uint) | `Binary` |
| `Binary` | [Decimal256](/pt-BR/reference/data-types/decimal) | `Binary` |
| `Union` | [Variant](/pt-BR/reference/data-types/variant) | `Union` |

* Outros tipos não são suportados.

- Uma coluna ORC `Union` é lida como um [Variant](/pt-BR/reference/data-types/variant) sobre os tipos de ramificação da união, e uma coluna `Variant` é gravada como uma `Union` ORC sobre seus tipos de ramificação. Observe que `Variant` ordena seus tipos de ramificação, portanto, a ordem das ramificações pode diferir do arquivo ORC. Uniões com tipos de ramificação duplicados (por exemplo, `uniontype<int,int>`) não são suportadas.

* Arrays podem ser aninhados e podem ter um valor do tipo `Nullable` como argumento. Os tipos `Tuple` e `Map` também podem ser aninhados.
* Os tipos de dados das colunas da tabela do ClickHouse não precisam corresponder aos campos de dados ORC correspondentes. Ao inserir dados, o ClickHouse interpreta os tipos de dados de acordo com a tabela acima e então [converte](/pt-BR/reference/functions/regular-functions/type-conversion-functions#CAST) os dados para o tipo de dado definido para a coluna da tabela do ClickHouse.

<div id="example-usage">
  ## Exemplo de uso
</div>

<div id="inserting-data">
  ### Inserção de dados
</div>

Use um arquivo ORC com os dados a seguir, chamado `football.orc`:

```text theme={null}
    ┌───────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 │
    └────────────┴────────┴───────────────────────┴─────────────────────┴─────────────────┴─────────────────┘
```

Insira os dados:

```sql theme={null}
INSERT INTO football FROM INFILE 'football.orc' FORMAT ORC;
```

<div id="reading-data">
  ### Leitura de dados
</div>

Leia os dados usando o formato `ORC`:

```sql theme={null}
SELECT *
FROM football
INTO OUTFILE 'football.orc'
FORMAT ORC
```

<Tip>
  ORC é um formato binário que não é exibido de forma legível para humanos no terminal. Use `INTO OUTFILE` para gerar arquivos ORC.
</Tip>

<div id="format-settings">
  ## Configurações de formato
</div>

| Configuração | Descrição | Padrão |
| - | - | - |
| [`output_format_orc_string_as_string`](/pt-BR/reference/settings/formats/output-format#output_format_orc_string_as_string) | Usa o tipo String do ORC em vez de Binary para colunas String. | `true` |
| [`output_format_orc_compression_method`](/pt-BR/reference/settings/formats/output-format#output_format_orc_compression_method) | Método de compressão usado no formato ORC de saída. Valor padrão. | `zstd` |
| [`input_format_orc_case_insensitive_column_matching`](/pt-BR/reference/settings/formats/input-format#input_format_orc_case_insensitive_column_matching) | Ignora maiúsculas e minúsculas ao corresponder colunas do ORC a colunas do ClickHouse. | `false` |
| [`input_format_orc_allow_missing_columns`](/pt-BR/reference/settings/formats/input-format#input_format_orc_allow_missing_columns) | Permite colunas ausentes ao ler dados ORC. | `true` |
| [`input_format_orc_skip_columns_with_unsupported_types_in_schema_inference`](/pt-BR/reference/settings/formats/input-format#input_format_orc_skip_columns_with_unsupported_types_in_schema_inference) | Permite ignorar colunas com tipos sem suporte durante a inferência de esquema no formato ORC. | `false` |

Para trocar dados com o Hadoop, você pode usar o [motor de tabela HDFS](/pt-BR/reference/engines/table-engines/integrations/hdfs).
