Added check of StorageView before checking parameterized view to fix seg fault when materialized view is used with brackets

This commit is contained in:
Smita Kulkarni 2023-06-22 14:47:04 +02:00
parent b7ef782335
commit 3c7d749d2c
3 changed files with 5 additions and 1 deletions

View File

@ -1476,7 +1476,7 @@ StoragePtr Context::executeTableFunction(const ASTPtr & table_expression, const
StoragePtr table = DatabaseCatalog::instance().tryGetTable({database_name, table_name}, getQueryContext());
if (table)
{
if (table.get()->isView() && table->as<StorageView>()->isParameterizedView())
if (table.get()->isView() && table->as<StorageView>() && table->as<StorageView>()->isParameterizedView())
{
function->prefer_subquery_to_function_formatting = true;
return table;

View File

@ -40,3 +40,4 @@ ERROR
10
10
1
ERROR

View File

@ -112,7 +112,10 @@ $CLICKHOUSE_CLIENT -q "CREATE VIEW 02428_trace_view AS WITH {trace_id:String} A
FROM 02428_otel_traces"
$CLICKHOUSE_CLIENT -q "SELECT * FROM 02428_trace_view(trace_id='1')"
$CLICKHOUSE_CLIENT -q "CREATE MATERIALIZED VIEW test_02428_mv1 ENGINE = ReplicatedMergeTree('/clickhouse/tables/$CLICKHOUSE_TEST_ZOOKEEPER_PREFIX/materialized_view', 'r1') ORDER BY Name AS SELECT * FROM test_02428_Catalog;"
$CLICKHOUSE_CLIENT -q "SELECT * FROM test_02428_mv1(test)" 2>&1 | grep -Fq "UNKNOWN_FUNCTION" && echo 'ERROR' || echo 'OK'
$CLICKHOUSE_CLIENT -q "DROP VIEW test_02428_mv1"
$CLICKHOUSE_CLIENT -q "DROP VIEW test_02428_pv1"
$CLICKHOUSE_CLIENT -q "DROP VIEW test_02428_pv2"
$CLICKHOUSE_CLIENT -q "DROP VIEW test_02428_pv3"