BTW spider has a udf called spider_copy_tables that copies data
from a src table to a set of dest tables:
https://mariadb.com/kb/en/spider_copy_tables/
All the src and dest tables are on the data nodes.
For example, say ta_l is a spider table with two remotes, then
SELECT spider_copy_tables('ta_l', '0', '1')
copies data from the 0th link to the 1st link.
This udf should satisfy the requirement in the ticket, where the
dest link is an empty local table. However it uses the deprecated
Spider HA (MDEV-28479), and it implements its own logic in selecting
from the src table in chunks of bulk_insert_rows and create
queries manually inserting them to the destination tables. If we
just want to implement what is requested in this ticket, i.e.
copying data from a remote table to a local table, then using the
existing alter table logic (amounting to removing the check on ALTER
TABLE in a previous comment) is simpler.
If we want to keep the functionality of copying from one possibly
remote table to another possibly remote, then it could be done
without HA also, with a new implementation of spider_copy_tables,
that does
{{SELECT spider_copy_tables(t1, t2)}
where t1 and t2 could be an arbitrary combination of spider and
local tables. If t1 is a spider table and t2 is a local table, then
it copies from the data node of t1 to t2. If both t1 and t2 are
spider tables, then it copies from the data node of t1 to the data
node of t2. And so on.
Special push down DDL mode suffers from ambiguity mentioned in my
previous comment: say t1 is a spider table, then in the special mode
alter table t1 engine=innodb
could mean alter the spider table t1 to an innodb table and move
the data from the data node table to t1, or it could mean simply
alter the data node table to an innodb table.
Going from SPIDER to S3, neither of these work