Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View alexey-milovidov's full-sized avatar

Alexey Milovidov alexey-milovidov

View GitHub Profile
@alexey-milovidov
alexey-milovidov / paste.txt
Created June 21, 2016 17:05
Check for constants in primary key.
$ clickhouse-client
ClickHouse client version 0.0.53720.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.53981.
:) create table hoba (naber Date) ENGINE = MergeTree(naber, (1, naber), 8192)
CREATE TABLE hoba
(
naber Date
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 113
Server version: 5.5.50-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
:) SELECT C_REGION, C_NATION, count(*) FROM lineorder_x3 GLOBAL ANY INNER JOIN ( SELECT C_REGION, C_NATION, C_CUSTKEY AS LO_CUSTKEY FROM customer_x3 ) USING (LO_CUSTKEY) WHERE (toYear(LO_ORDERDATE) > 1993) AND (LO_DISCOUNT >= 1) AND (LO_QUANTITY < 25) GROUP BY C_REGION, C_NATION;
SELECT
C_REGION,
C_NATION,
count(*)
FROM lineorder_x3
GLOBAL ANY INNER JOIN
(
SELECT
@alexey-milovidov
alexey-milovidov / graphite_sizes.txt
Created July 27, 2016 01:20
Example of column sizes in graphite table.
:) SELECT name, formatReadableSize(sum(bytes)) FROM system.columns WHERE table = 'graphite_impl' AND database = 'default' GROUP BY name ORDER BY sum(bytes) DESC
SELECT
name,
formatReadableSize(sum(bytes))
FROM system.columns
WHERE (table = 'graphite_impl') AND (database = 'default')
GROUP BY name
ORDER BY sum(bytes) DESC
:) SELECT number % 3 AS key, number AS x FROM system.numbers LIMIT 10
SELECT
number % 3 AS key,
number AS x
FROM system.numbers
LIMIT 10
┌─key─┬─x─┐
│ 0 │ 0 │
=================================================================
==260044:302867==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61500060db01 at pc 0x00000cf8e0a5 bp 0x7f0359a478f0 sp 0x7f0359a478e8
WRITE of size 8 at 0x61500060db01 thread T3436
#0 0xcf8e0a4 (/usr/bin/clickhouse+0xcf8e0a4)
#1 0xcf8e42b (/usr/bin/clickhouse+0xcf8e42b)
#2 0xcf8f39f (/usr/bin/clickhouse+0xcf8f39f)
#3 0xcf8f78c (/usr/bin/clickhouse+0xcf8f78c)
#4 0xcdef1df (/usr/bin/clickhouse+0xcdef1df)
#5 0xcddf6af (/usr/bin/clickhouse+0xcddf6af)
#6 0xcde32bb (/usr/bin/clickhouse+0xcde32bb)
Old:
Running: float_parsing
[
{
"hostname": "",
"main_metric": "avg_rows_per_second",
"num_cores": 16,
"num_threads": 32,
"parameters": {
ClickHouse client version 1.1.54371.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54371.
localhost :) USE test
USE test
Ok.
@alexey-milovidov
alexey-milovidov / test.txt
Created April 18, 2018 21:07
Parsing array of wrong type
$ echo '[1, -1]' | clickhouse-local -S 'x Array(UInt8)' --query="SELECT * FROM table"
Code: 130, e.displayText() = DB::Exception: Cannot read array from text: (at row 1)
Row 1:
Column 0, name: x, type: Array(UInt8), parsed text: "[1, "ERROR
, e.what() = DB::Exception (from 0.0.0.0:0) (in query: SELECT * FROM table), Stack trace:
0. clickhouse-local(StackTrace::StackTrace()+0x12) [0x53d67b2]
1. clickhouse-local(DB::DataTypeArray::deserializeText(DB::IColumn&, DB::ReadBuffer&) const+0x2a4) [0x7e69cb4]
SELECT user_id, arrayReduce('sum',[if(f21<0.287376, if(f2<-1.34168, if(f21<-0.0465033, -0.0411413, -0.0168165), if(f18<0.0541038, -0.0486026, -0.0432873)), if(f2<-1.12007, if(f19<0.514323, -0.00154215, 0.0279125), if(f23<-0.0269176, -0.0391427, -0.0148464))),if(f21<0.287376, if(f2<-1.30474, if(f21<-0.0465033, -0.0407256, -0.0184058), if(f23<-0.0274336, -0.0469912, -0.0290771)), if(f2<-1.157, if(f23<-0.027484, -0.00114219, 0.029407), if(f2<-0.344426, -0.0242555, -0.0423453))),if(f18<0.883746, if(f2<-1.34168, if(f21<-0.00940569, -0.0386349, -0.00968768), if(f23<-0.0274894, -0.0458335, -0.0281316)), if(f2<-1.30474, if(f23<-0.0273632, -0.00346079, 0.0302068), if(f19<0.514323, -0.0340366, -0.00648281))),if(f21<0.250278, if(f2<-1.34168, if(f21<-0.0465033, -0.0383863, -0.0166084), if(f18<0.0541038, -0.0453193, -0.0402171)), if(f2<-1.30474, if(f22<0.233904, 0.00176162, 0.0268355), if(f2<-0.639908, -0.0178382, -0.0385038))),if(f18<0.607199, if(f2<-1.34168, if(f21<-0.00940569, -0.0373913, -0.0101554), if(f23<-0.0274336