ClickHouse v.21.7.7.47

setting max_memory_usage doesnt work for 'create table .. as' queries

for example:
**this query works**
`create table test_table engine MergeTree order by a as
select a_table.a, b_table.b_arr
from (select arrayJoin(range(10000)) as a) a_table
         cross join (select range(10000) as b_arr) b_table
    settings max_memory_usage = 1;`

**this query doesnt work**
`insert into test_table
select a_table.a, b_table.b_arr
from (select arrayJoin(range(10000)) as a) a_table
         cross join (select range(10000) as b_arr) b_table
    settings max_memory_usage = 1;`
With error:
`DB::Exception: Memory limit (for query) exceeded: would use 4.09 MiB`

**Expected behavior**
**this query should NOT work, and setting max_memory_usage should work for all 'select'\'insert'\'create table' queries**
`create table test_table engine MergeTree order by a as
select a_table.a, b_table.b_arr
from (select arrayJoin(range(10000)) as a) a_table
         cross join (select range(10000) as b_arr) b_table
    settings max_memory_usage = 1;`
#include <Processors/Transforms/MaterializingTransform.h>
#include <Processors/Formats/IOutputFormat.h>
#include <Processors/Sources/SinkToOutputStream.h>
#include <random>
namespace ProfileEvents
{
    extern const Event QueryMaskingRulesMatch;
    extern const Event FailedQuery;
    extern const Event FailedInsertQuery;
    extern const Event FailedSelectQuery;
    extern const Event QueryTimeMicroseconds;
    extern const Event SelectQueryTimeMicroseconds;
    extern const Event InsertQueryTimeMicroseconds;
}
namespace DB
{
namespace ErrorCodes
{
    extern const int INTO_OUTFILE_NOT_ALLOWED;
    extern const int QUERY_WAS_CANCELLED;
    extern const int LOGICAL_ERROR;
}
static void checkASTSizeLimits(const IAST & ast, const Settings & settings)
{
    if (settings.max_ast_depth)
        ast.checkDepth(settings.max_ast_depth);
    if (settings.max_ast_elements)
        ast.checkSize(settings.max_ast_elements);
}
static String joinLines(const String & query)