Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias columns should not allow codec #47332

Closed
pliakhavets opened this issue Mar 8, 2023 · 0 comments · Fixed by #49363
Closed

Alias columns should not allow codec #47332

pliakhavets opened this issue Mar 8, 2023 · 0 comments · Fixed by #49363
Assignees
Labels
easy task Good for first contributors unexpected behaviour

Comments

@pliakhavets
Copy link

Column ALIAS should not allow codec
Alias column (as a non-materialized one) should probably not allow adding codec

How to reproduce

  • server version: ClickHouse server version 22.12.3 revision 54461.
  • client: ClickHouse client version 22.12.3.5 (official build).
  • Non-default settings: seems none relevant
  • Sample data - unnecessary
  • Queries to run:
create database if not exists tmp;

create table if not exists tmp.alias_column_should_not_allow_compression ( user_id UUID, user_id_hashed ALIAS (cityHash64(user_id)))
engine MergeTree
partition by tuple()
order by tuple()
;

/* -- generate alters
select --name, type,
    'alter table '|| database || '.' || table || ' modify column `' || name || '` ' || type || ' codec(LZ4HC(1));'
from system.columns where database = 'tmp' and table = 'alias_column_should_not_allow_compression' and compression_codec = ''
;
*/

alter table tmp.alias_column_should_not_allow_compression modify column `user_id_hashed` UInt64 codec(LZ4HC(1));
-- performed ok, though I understand that it makes no sense for alias - missed in bulk operation and no possibility to override on table's MergeTree settings level for default

detach table tmp.alias_column_should_not_allow_compression;

attach table tmp.alias_column_should_not_allow_compression;
-- throws error (same for server restart - loops daemon startup)
-- Received exception from server (version 22.12.3):
-- Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Cannot specify codec for column type ALIAS. (BAD_ARGUMENTS)

Expected behavior
I suppose best here - is to throw on alter attempt (but disregard of codec on attach/operation of alias column is an option as well)


Additional context

-- 1 - how to drop table in such situation? or remove replica?
drop table tmp.alias_column_should_not_allow_compression;
-- returns 
-- Received exception from server (version 22.12.3):
-- Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Table tmp.alias_column_should_not_allow_compression doesn't exist. (UNKNOWN_TABLE)
create or replace table tmp.alias_column_should_not_allow_compression ( user_id UUID, user_id_hashed ALIAS (cityHash64(user_id)))
engine MergeTree
partition by tuple()
order by tuple()
;
-- returns:
-- Received exception from server (version 22.12.3):
-- Code: 57. DB::Exception: Received from localhost:9000. DB::Exception: Table `tmp`.`alias_column_should_not_allow_compression` already exists (detached). (TABLE_ALREADY_EXISTS)
replace table tmp.alias_column_should_not_allow_compression ( user_id UUID, user_id_hashed ALIAS (cityHash64(user_id)))
engine MergeTree
partition by tuple()
order by tuple()
;
-- returns:
-- Received exception from server (version 22.12.3):
-- Code: 60. DB::Exception: Received from localhost:9000. DB::Exception: Table `tmp`.`alias_column_should_not_allow_compression` doesn't exist. (UNKNOWN_TABLE)

-- *if there is a way do it by SQL - please let me know (we resolved only via manipulations with ZK and afterwadrs restore of replica)


-- 2 - exception readability
create table if not exists tmp.alias_column_should_not_allow_compression_2 ( user_id UUID, user_id_hashed ALIAS (cityHash64(user_id)))
engine MergeTree
partition by tuple()
order by tuple()
;

alter table tmp.alias_column_should_not_allow_compression_2 modify column if exists `user_id_hashed` remove CODEC;
-- if column has no codec - throws: ...doesn't have TTL ... - may be would be better readable if parametrized like ...doesn't have {item_property_to_remove}...
-- Received exception from server (version 22.12.3):
-- Code: 36. DB::Exception: Received from localhost:9000. DB::Exception: Column `user_id_hashed` doesn't have TTL, cannot remove it. (BAD_ARGUMENTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
easy task Good for first contributors unexpected behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants