Skip to content

Instantly share code, notes, and snippets.

@tiagocardosos
Created February 8, 2023 18:29
Show Gist options
  • Save tiagocardosos/3fd04b1e03335625eb74a10727e3d2a8 to your computer and use it in GitHub Desktop.
Save tiagocardosos/3fd04b1e03335625eb74a10727e3d2a8 to your computer and use it in GitHub Desktop.
ClickhouseDb - POC

Tabela exemplo

CREATE TABLE capes
(
    `id` String,
    `title` Array(String),
    `year` UInt16,
    `documentType` String,
    `abstract` Array(String),
    `subjects` Array(String),
    `sourceName` Array(String),
    `graduateProgram` Array(String),
    `graduateProgramId` Array(String),
    `capesResearchGreatArea` Array(String),
    `lang` String,
    `lattesId` String,
    `cnpqArea` Array(String)

)
ENGINE = MergeTree
ORDER BY (title, year, lang);

Visualizando conteúdo json

SELECT * FROM
 INFILE 'http://127.0.0.1:9000/capes/dataset/00000424c18cc9376ddd5a9916e77487.json?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=7PX21H2IK7SMRK44ZRZF%2F20230131%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230131T193751Z&X-Amz-Expires=604800&X-Amz-Security-Token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2Nlc3NLZXkiOiI3UFgyMUgySUs3U01SSzQ0WlJaRiIsImV4cCI6MTY3NTIzNjcyNywicGFyZW50Ijoicm9vdCJ9.JRbiZGLZgtdMTnJlFJY4Cn1nscq6z2n4aWwRkeqDKxKMTGY38T9gQTTjKdVfvFFFzkRNK5zNF4Trz3kbjPcS7g&X-Amz-SignedHeaders=host&versionId=null&X-Amz-Signature=b5c09c4e2525f79ea01edb28a74823784b3b7525dbe211ace749f756b895a3bd'
FORMAT JSONEachRow;

Inserindo conteudo json

SET allow_experimental_object_type = 1; #JSONAsObject

INSERT INTO json_test.capes SELECT *
FROM s3('http://127.0.0.1:9000/capes/dataset/00000424c18cc9376ddd5a9916e77487.json', 'JSONAsObject')
LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment