mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Merge pull request #56236 from evillique/fix-dictionaries
Fix ClickHouse-sourced dictionaries with an explicit query
This commit is contained in:
commit
dd326729a3
@ -396,18 +396,20 @@ std::string ExternalQueryBuilder::composeLoadKeysQuery(
|
||||
}
|
||||
else
|
||||
{
|
||||
writeString(query, out);
|
||||
|
||||
auto condition_position = query.find(CONDITION_PLACEHOLDER_TO_REPLACE_VALUE);
|
||||
if (condition_position == std::string::npos)
|
||||
{
|
||||
writeString(" WHERE ", out);
|
||||
writeString("SELECT * FROM (", out);
|
||||
writeString(query, out);
|
||||
writeString(") WHERE ", out);
|
||||
composeKeysCondition(key_columns, requested_rows, method, partition_key_prefix, out);
|
||||
writeString(";", out);
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
writeString(query, out);
|
||||
|
||||
WriteBufferFromOwnString condition_value_buffer;
|
||||
composeKeysCondition(key_columns, requested_rows, method, partition_key_prefix, condition_value_buffer);
|
||||
const auto & condition_value = condition_value_buffer.str();
|
||||
|
@ -0,0 +1 @@
|
||||
b
|
20
tests/queries/0_stateless/02907_clickhouse_dictionary_bug.sh
Executable file
20
tests/queries/0_stateless/02907_clickhouse_dictionary_bug.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: zookeeper
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CLIENT} -n -q "
|
||||
DROP DICTIONARY IF EXISTS 02907_dictionary;
|
||||
DROP TABLE IF EXISTS 02907_table;
|
||||
|
||||
CREATE TABLE 02907_table (A String, B String) ENGINE=Memory AS SELECT 'a', 'b';
|
||||
CREATE DICTIONARY 02907_dictionary(A String, B String) PRIMARY KEY A
|
||||
SOURCE(CLICKHOUSE(QUERY \$\$ SELECT A, B FROM ${CLICKHOUSE_DATABASE}.02907_table ORDER BY A DESC LIMIT 1 BY A \$\$))
|
||||
LAYOUT(complex_key_direct());
|
||||
|
||||
SELECT dictGet('02907_dictionary','B','a');
|
||||
|
||||
DROP DICTIONARY 02907_dictionary;
|
||||
DROP TABLE 02907_table;"
|
Loading…
Reference in New Issue
Block a user