Criar uma nova tabela no storage
Create Table
Cria uma nova tabela no Snowflake com schema especificado.
Endpoint
POST /storage-explorer/tables
Permissões Requeridas
STORAGE_EXPLORER.WRITE
Request Body
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
table_name | string | Sim | Nome da tabela |
schema_name | string | Sim | Schema onde a tabela será criada |
columns | array | Sim | Lista de colunas da tabela |
columns[].name | string | Sim | Nome da coluna |
columns[].type | string | Sim | Tipo de dado (VARCHAR, INTEGER, TIMESTAMP, etc.) |
columns[].nullable | boolean | Não | Se a coluna aceita NULL (padrão: true) |
columns[].primary_key | boolean | Não | Se a coluna é chave primária |
description | string | Não | Descrição da tabela |
Tipos de Dados Suportados
VARCHAR(n)- String de tamanho variávelINTEGER- Número inteiroBIGINT- Número inteiro grandeDECIMAL(p,s)- Número decimalFLOAT- Número de ponto flutuanteTIMESTAMP- Data e horaDATE- DataBOOLEAN- BooleanoJSON- JSON/VARIANT
Exemplo de Requisição
curl -X POST "https://maestro.dadosfera.ai/storage-explorer/tables" \
-H "Authorization: <JWT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"table_name": "customer_orders",
"schema_name": "RAW_DATA",
"description": "Tabela de pedidos de clientes",
"columns": [
{
"name": "order_id",
"type": "VARCHAR(50)",
"nullable": false,
"primary_key": true
},
{
"name": "customer_id",
"type": "VARCHAR(50)",
"nullable": false
},
{
"name": "order_date",
"type": "TIMESTAMP",
"nullable": false
},
{
"name": "total_amount",
"type": "DECIMAL(10,2)",
"nullable": true
},
{
"name": "status",
"type": "VARCHAR(20)",
"nullable": false
}
]
}'Exemplo de Resposta
Success (201 Created):
{
"table_id": "tbl_a1b2c3d4e5f6",
"table_name": "customer_orders",
"schema_name": "RAW_DATA",
"full_name": "RAW_DATA.customer_orders",
"created_at": "2024-01-15T10:30:00Z",
"columns": [
{
"name": "order_id",
"type": "VARCHAR(50)",
"nullable": false,
"primary_key": true
},
{
"name": "customer_id",
"type": "VARCHAR(50)",
"nullable": false,
"primary_key": false
},
{
"name": "order_date",
"type": "TIMESTAMP",
"nullable": false,
"primary_key": false
},
{
"name": "total_amount",
"type": "DECIMAL(10,2)",
"nullable": true,
"primary_key": false
},
{
"name": "status",
"type": "VARCHAR(20)",
"nullable": false,
"primary_key": false
}
],
"description": "Tabela de pedidos de clientes"
}Códigos de Status
| Código | Descrição |
|---|---|
201 | Tabela criada com sucesso |
400 | Parâmetros inválidos ou nome de tabela inválido |
401 | Não autenticado |
403 | Sem permissão STORAGE_EXPLORER.WRITE |
409 | Tabela já existe |
500 | Erro ao criar tabela no Snowflake |
