> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-home-button.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 tipos de dados correspondentes do ClickHouse em consultas `INSERT` e `SELECT`.

| Tipo de dado ORC (`INSERT`)           | Tipo de dado ClickHouse                                                                         | Tipo de dado ORC (`SELECT`) |
| ------------------------------------- | ----------------------------------------------------------------------------------------------- | --------------------------- |
| `Boolean`                             | [UInt8](/pt-BR/reference/data-types/int-uint)                                                   | `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/UInt32](/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`, `Char`, `Varchar`, `Binary` | [String](/pt-BR/reference/data-types/string)                                                    | `Binary`                    |
| `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/ipv4)                                                        | `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`                    |
| `String`, `Char`, `Varchar`, `Binary` | [String](/pt-BR/reference/data-types/string)                                                    | `Binary`                    |

* Outros tipos não são suportados.
* 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_arrow_string_as_string`](/pt-BR/reference/settings/formats#output_format_arrow_string_as_string)                                                                             | Usa o tipo String do Arrow em vez de Binary para colunas String.                                | `false` |
| [`output_format_orc_compression_method`](/pt-BR/reference/settings/formats#output_format_orc_compression_method)                                                                             | Método de compressão usado no formato ORC de saída. Valor padrão.                               | `none`  |
| [`input_format_arrow_case_insensitive_column_matching`](/pt-BR/reference/settings/formats#input_format_arrow_case_insensitive_column_matching)                                               | Ignora maiúsculas e minúsculas ao corresponder colunas do Arrow a colunas do ClickHouse.        | `false` |
| [`input_format_arrow_allow_missing_columns`](/pt-BR/reference/settings/formats#input_format_arrow_allow_missing_columns)                                                                     | Permite colunas ausentes ao ler dados Arrow.                                                    | `false` |
| [`input_format_arrow_skip_columns_with_unsupported_types_in_schema_inference`](/pt-BR/reference/settings/formats#input_format_arrow_skip_columns_with_unsupported_types_in_schema_inference) | Permite ignorar colunas com tipos sem suporte durante a inferência de esquema no formato Arrow. | `false` |

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