Skip to content

Commit

Permalink
Merge pull request #60837 from ClickHouse/backport/23.8/60765
Browse files Browse the repository at this point in the history
Backport #60765 to 23.8: Fix crash when using input() in INSERT SELECT JOIN
  • Loading branch information
Avogar committed Mar 6, 2024
2 parents 09d12c6 + a02f202 commit 37cafd9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,7 @@ StoragePtr Context::executeTableFunction(const ASTPtr & table_expression, const
}

uint64_t use_structure_from_insertion_table_in_table_functions = getSettingsRef().use_structure_from_insertion_table_in_table_functions;
if (use_structure_from_insertion_table_in_table_functions && table_function_ptr->needStructureHint() && hasInsertionTable())
if (select_query_hint && use_structure_from_insertion_table_in_table_functions && table_function_ptr->needStructureHint() && hasInsertionTable())
{
const auto & insert_structure = DatabaseCatalog::instance()
.getTable(getInsertionTable(), shared_from_this())
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
14 changes: 14 additions & 0 deletions tests/queries/0_stateless/03005_input_function_in_join.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
drop table if exists test;
create table test (a Int8) engine = MergeTree order by tuple();
INSERT INTO test
SELECT x.number FROM (
SELECT number
FROM system.numbers
LIMIT 10
) AS x
INNER JOIN input('a UInt64') AS y ON x.number = y.a
Format CSV 2
;
select * from test;
drop table test;

0 comments on commit 37cafd9

Please sign in to comment.