Skip to content

Commit

Permalink
Fix dictGet arguments check during GROUP BY injective functions elimi…
Browse files Browse the repository at this point in the history
…nation

This patch changes the place where the dictionary will be loaded (during
syntax analysis), but I guess this is fine, it will be loaded anyway.

Fixes: ClickHouse#10342
  • Loading branch information
azat committed Jul 6, 2020
1 parent 6310e49 commit 128dd4f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Interpreters/SyntaxAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ void executeScalarSubqueries(ASTPtr & query, const Context & context, size_t sub

const std::unordered_set<String> possibly_injective_function_names
{
"dictGet",
"dictGetString",
"dictGetUInt8",
"dictGetUInt16",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
-- https://github.com/ClickHouse/ClickHouse/issues/11469
SELECT dictGet('default.countryId', 'country', toUInt64(number)) AS country FROM numbers(2) GROUP BY country; -- { serverError 36; }


-- with real dictionary
DROP TABLE IF EXISTS dictdb_01376.table_for_dict;
DROP DICTIONARY IF EXISTS dictdb_01376.dict_exists;
DROP DATABASE IF EXISTS dictdb_01376;

CREATE DATABASE dictdb_01376 ENGINE = Ordinary;

CREATE TABLE dictdb_01376.table_for_dict
(
key_column UInt64,
value Float64
)
ENGINE = Memory();

INSERT INTO dictdb_01376.table_for_dict VALUES (1, 1.1);

CREATE DICTIONARY IF NOT EXISTS dictdb_01376.dict_exists
(
key_column UInt64,
value Float64 DEFAULT 77.77
)
PRIMARY KEY key_column
SOURCE(CLICKHOUSE(HOST 'localhost' PORT 9000 USER 'default' TABLE 'table_for_dict' DB 'dictdb_01376'))
LIFETIME(1)
LAYOUT(FLAT());

SELECT dictGet('dictdb_01376.dict_exists', 'value', toUInt64(1)) as val FROM numbers(2) GROUP BY val;

0 comments on commit 128dd4f

Please sign in to comment.