Skip to content

Instantly share code, notes, and snippets.

View gingerwizard's full-sized avatar

Dale McDiarmid gingerwizard

View GitHub Profile
DESCRIBE TABLE gcs('https://storage.googleapis.com/clickhouse-website/ga-*.parquet', '<access key>', '<secret>')
FORMAT TSV

event_date    Nullable(String)
event_timestamp    Nullable(Int64)
event_name    Nullable(String)
event_params    Array(Tuple(key Nullable(String), value Tuple(string_value Nullable(String), int_value Nullable(Int64), float_value Nullable(Float64), double_value Nullable(Float64))))
event_previous_timestamp    Nullable(Int64)
event_value_in_usd    Nullable(Float64)
/*-----------------------------------------------------------------------*/
/* Program: STREAM */
/* Revision: $Id: stream.c,v 5.10 2013/01/17 16:01:06 mccalpin Exp mccalpin $ */
/* Original code developed by John D. McCalpin */
/* Programmers: John D. McCalpin */
/* Joe R. Zagar */
/* */
/* This program measures memory transfer rates in MB/s for simple */
/* computational kernels coded in C. */
/*-----------------------------------------------------------------------*/
name alpha-2 country-code
Afghanistan AF 004
Åland Islands AX 248
Albania AL 008
Algeria DZ 012
American Samoa AS 016
Andorra AD 020
Angola AO 024
Anguilla AI 660
Antarctica AQ 010
name alpha-2 country-code
Afghanistan AF 004
Åland Islands AX 248
Albania AL 008
Algeria DZ 012
American Samoa AS 016
Andorra AD 020
Angola AO 024
Anguilla AI 660
Antarctica AQ 010
name alpha-2 country-code
Afghanistan AF 004
Åland Islands AX 248
Albania AL 008
Algeria DZ 012
American Samoa AS 016
Andorra AD 020
Angola AO 024
Anguilla AI 660
Antarctica AQ 010
SELECT
    url,
    caption,
    L2Distance(image_embedding, [0.5736792683601379, 0.2516227662563324, 0.08648405969142914, -0.3087577521800995, 0.16166526079177856, -0.007050537504255772, -0.18505804240703583, -0.4547903835773468, -0.27521055936813354, -0.14916469156742096, -0.3867589235305786, -0.6603131294250488, -0.12612514197826385, 0.0861508697271347, -0.3013170063495636, -0.18740114569664001, -0.47240784764289856, 0.23528385162353516, 0.2165445238351822, -0.14971637725830078, -0.11677167564630508, 0.16455139219760895, 0.6751934885978699, 0.48457151651382446, -0.6089483499526978, 0.1328628659248352, 0.1305725872516632, -0.27523916959762573, 0.6474258899688721, 0.6060798764228821, 0.09428835660219193, -0.059794556349515915, -0.17287959158420563, 0.03964110463857651, -0.223852276802063, -0.026328448206186295, 0.16255885362625122, 0.39999595284461975, -0.2318170964717865, 0.5195636749267578, 0.35400936007499695, -0.3005162477493286, 0.581500768661499, -0.08902442455291748, -0.09745857864618301, -0.32

Below creates a Parquet file with 1 row group for UK house price dataset (28m rows, approx. 200mb Parquet with LZ4):

INSERT INTO FUNCTION file('house_prices-1-row-group.parquet') SELECT *
FROM uk_price_paid
SETTINGS min_insert_block_size_bytes = 10000000000, 
min_insert_block_size_rows=1000000000, 
output_format_parquet_row_group_size=1000000000               

The following assumes use of clickhouse-local, although these steps will alsowork with ClickHouse server.

1. Create table

CREATE TABLE uk_price_paid
(
    `price` UInt32,
    `date` Date,
    `postcode1` LowCardinality(String),
EXPLAIN indexes = 1
SELECT
    Timestamp,
    TraceId,
    SpanId,
    SpanName
FROM otel_traces
WHERE TraceId = '0f8a2c02d77d65da6b2c4d676985b3ab'

Trace data

Supplements queries documented as part of ClickHouse exporter.

Traces over Time

SELECT toStartOfInterval(toDateTime(Timestamp), INTERVAL 60 second) as time, ServiceName, count() as ` ` 
FROM otel."otel_traces" WHERE 1=1 AND Timestamp >= '1679994670' AND Timestamp <= '1679998270'  AND 
ServiceName In ('accountingservice','adservice','cartservice','checkoutservice','currencyservice','emailservice',