Support references to unknown tables in remote table functions#83844
Support references to unknown tables in remote table functions#83844
Conversation
vdimir
left a comment
There was a problem hiding this comment.
It might be a good idea to add a test for this case, an integration test, at the very least, should be feasible.
| if (table_function_node->getTableFunctionName() == "view") | ||
| { | ||
| auto get_column_options = GetColumnsOptions(GetColumnsOptions::All).withExtendedObjects().withVirtuals(); | ||
| auto column_names_and_types = distributed_storage_snapshot->getColumns(get_column_options); |
There was a problem hiding this comment.
How columns from distributed_storage_snapshot can be different from local analysis of table_function_node in case we have tables on all nodes? Is it the same? What if tables are present on all nodes, but has different structures?
There was a problem hiding this comment.
Table structure can't differ on the shard because it's initialized from the structure request in getStructureOfRemoteTable. And we got in during table function analysis in QueryAnalyzer.
This code solves the problem that in remove(..., view(<>))expression view(<>) is not a resolved query tree and we can't resolve it on the initiator. It was resolved on the shard during the call in getStructureOfRemoteTable.
| StorageID remote_storage_id = StorageID::createEmpty(); | ||
| if (!remote_table_function_ptr) | ||
| remote_storage_id = StorageID{remote_database, remote_table}; | ||
| StorageID remote_storage_id = StorageID{remote_database, remote_table}; |
There was a problem hiding this comment.
This is a bit controversial change, because for table functions it is always system.one.
Cherry pick #83844 to 24.8: Support references to unknown tables in remote table functions
Cherry pick #83844 to 25.3: Support references to unknown tables in remote table functions
Cherry pick #83844 to 25.4: Support references to unknown tables in remote table functions
Cherry pick #83844 to 25.5: Support references to unknown tables in remote table functions
Cherry pick #83844 to 25.6: Support references to unknown tables in remote table functions
Cherry pick #83844 to 25.7: Support references to unknown tables in remote table functions
Backport #83844 to 25.7: Support references to unknown tables in remote table functions
Backport #83844 to 25.6: Support references to unknown tables in remote table functions
Backport #83844 to 25.5: Support references to unknown tables in remote table functions
Backport #83844 to 25.3: Support references to unknown tables in remote table functions
…es in remote table functions
Backport ClickHouse#83844 to 24.8: Support references to unknown tables in remote table functions
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Allow referencing any table in
view(...)argument ofremotetable function with enabled analyzer. Fixes #78717. Fixes #79377.Documentation entry for user-facing changes