ClickHouse/dbms/tests/queries/0_stateless/00826_indices_alter.sql
Nikita Vasilev a1b0dede07 Data Skipping Indices (#4143)
* made index parser

* added index parsing

* some fixes

* added index interface and factory

* fixed compilation

* ptrs

* added indexParts

* indextypes

* index condition

* IndexCondition

* added indexes in selectexecutor

* fix

* changed comment

* fix

* added granularity

* comments

* fix

* fix

* added writing indexes

* removed indexpart class

* fix

* added setSkipIndexes

* add rw for MergeTreeIndexes

* fixes

* upd error

* fix

* fix

* reading

* test index

* fixed nullptr error

* fixed

* fix

* unique names

* asts -> exprlist

* minmax index

* fix

* fixed select

* fixed merging

* fixed mutation

* working minmax

* removed test index

* fixed style

* added indexes to checkDataPart

* added tests for minmax index

* fixed constructor

* fix style

* fixed includes

* fixed setSkipIndexes

* added indexes meta to zookeeper

* added parsing

* removed throw

* alter cmds parse

* fix

* added alter

* fix

* alters fix

* fix alters

* fix "after"

* fixed alter

* alter fix + test

* fixes

* upd setSkipIndexes

* fixed alter bug with drop all indices

* fix metadata editing

* new test and repl fix

* rm test files

* fixed repl alter

* fix

* fix

* indices

* MTReadStream

* upd test for bug

* fix

* added useful parsers and ast classes

* fix

* fix comments

* replaced columns

* fix

* fixed parsing

* fixed printing

* fix err

* basic IndicesDescription

* go to IndicesDescr

* moved indices

* go to indicesDescr

* fix test minmax_index*

* fixed MT alter

* fixed bug with replMT indices storing in zk

* rename

* refactoring

* docs ru

* docs ru

* docs en

* refactor

* rename tests

* fix docs

* refactoring

* fix

* fix

* fix

* fixed style

* unique idx

* unique

* fix

* better minmax calculation

* upd

* added getBlock

* unique_condition

* added termForAST

* unique

* fixed not

* uniqueCondition::mayBeTrueOnGranule

* fix

* fixed bug with double column

* is always true

* fix

* key set

* spaces

* test

* tests

* fix

* unique

* fix

* fix

* fixed bug with duplicate column

* removed unused data

* fix

* fixes

* __bitSwapLastTwo

* fix
2019-02-05 17:50:25 +03:00

68 lines
1.8 KiB
SQL

DROP TABLE IF EXISTS test.minmax_idx;
DROP TABLE IF EXISTS test.minmax_idx2;
CREATE TABLE test.minmax_idx
(
u64 UInt64,
i32 Int32
) ENGINE = MergeTree()
ORDER BY u64;
INSERT INTO test.minmax_idx VALUES (1, 2);
ALTER TABLE test.minmax_idx ADD INDEX idx1 u64 * i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx ADD INDEX idx2 u64 + i32 TYPE minmax GRANULARITY 10;
ALTER TABLE test.minmax_idx ADD INDEX idx3 (u64 - i32) TYPE minmax GRANULARITY 10 AFTER idx1;
SHOW CREATE TABLE test.minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
INSERT INTO test.minmax_idx VALUES (1, 2);
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx DROP INDEX idx1;
SHOW CREATE TABLE test.minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx DROP INDEX idx2;
ALTER TABLE test.minmax_idx DROP INDEX idx3;
SHOW CREATE TABLE test.minmax_idx;
ALTER TABLE test.minmax_idx ADD INDEX idx1 (u64 * i32) TYPE minmax GRANULARITY 10;
SHOW CREATE TABLE test.minmax_idx;
SELECT * FROM test.minmax_idx WHERE u64 * i32 = 2;
CREATE TABLE test.minmax_idx2
(
u64 UInt64,
i32 Int32,
INDEX idx1 (u64 + i32) TYPE minmax GRANULARITY 10,
INDEX idx2 u64 * i32 TYPE minmax GRANULARITY 10
) ENGINE = MergeTree()
ORDER BY u64;
INSERT INTO test.minmax_idx2 VALUES (1, 2);
INSERT INTO test.minmax_idx2 VALUES (1, 2);
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
ALTER TABLE test.minmax_idx2 DROP INDEX idx1, DROP INDEX idx2;
SHOW CREATE TABLE test.minmax_idx2;
SELECT * FROM test.minmax_idx2 WHERE u64 * i32 = 2;
DROP TABLE test.minmax_idx;
DROP TABLE test.minmax_idx2;