Skip to content

Commit

Permalink
Merge pull request #6968 from azat-archive/create_as_skip_indices
Browse files Browse the repository at this point in the history
[RFC] Introduce create_as_skip_indices
  • Loading branch information
alexey-milovidov committed Sep 20, 2019
2 parents c3e0f1c + 1dc58dc commit f8d19f6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dbms/src/Interpreters/InterpreterCreateQuery.cpp
Expand Up @@ -2,6 +2,7 @@

#include <Poco/File.h>

#include <Common/StringUtils/StringUtils.h>
#include <Common/escapeForFileName.h>
#include <Common/typeid_cast.h>

Expand Down Expand Up @@ -416,7 +417,12 @@ ColumnsDescription InterpreterCreateQuery::setProperties(
else if (!create.as_table.empty())
{
columns = as_storage->getColumns();
indices = as_storage->getIndices();

/// Secondary indices make sense only for MergeTree family of storage engines.
/// We should not copy them for other storages.
if (create.storage && endsWith(create.storage->engine->name, "MergeTree"))
indices = as_storage->getIndices();

constraints = as_storage->getConstraints();
}
else if (create.select)
Expand Down
Empty file.
@@ -0,0 +1,5 @@
SET allow_experimental_data_skipping_indices=1;
CREATE TABLE foo (key int, INDEX i1 key TYPE minmax GRANULARITY 1) Engine=MergeTree() ORDER BY key;
CREATE TABLE as_foo AS foo;
CREATE TABLE dist (key int, INDEX i1 key TYPE minmax GRANULARITY 1) Engine=Distributed(test_shard_localhost, currentDatabase(), 'foo'); -- { serverError 36 }
CREATE TABLE dist_as_foo Engine=Distributed(test_shard_localhost, currentDatabase(), 'foo') AS foo;

0 comments on commit f8d19f6

Please sign in to comment.