Goal is to find out (initial_)query_id of INSERT query that triggered this (current) Materialized View execution, in order to register this initial_query_id in statistics table.
Why? It would enrich statistics/monitoring/troubleshooting and provide significant information both about origins of insert to ClickHouse and about propagation of insert through ClickHouse derived objects (e.g. in-ClickHouse latency).

The point is that system.query_log with all its useful information knows nothing about data.
At the same time manual statistics table(s) that are filled by adjacent MV potentially know everything about incoming data, but lack information about initial IP's, queries etc.
These two statistic's sources are crying to be linked together.

This use case and this desire look general enough, so there is probably some general solution.

+++++++++++++++++++++++++++
Details
+++++++++++++++++++++++++++

Input data stream enters my ClickHouse cluster through input Null table (on every node). 
Several Materialized Views over this Null table are performing some processing and propagating data further (there are distributed tables and more MV's there). 
In order to reduce in-ClickHouse latency: parallel_view_processing=1

One of derived tables (stat2.inserts_v02) contains statistics about input flow  (count(), quantiles, delays) over some data-related dimensions.
It is basic ReplicatedMergeTree that is filled via MV from inserts to initial Null table data2.input_null like:
`CREATE MATERIALIZED VIEW data2.inserts_v02_MVst2 ON CLUSTER ch_sNr1 TO stat2.inserts_v02
AS SELECT
  <data dimensions>,
  hostName(),
  count(), median(), etc
  FROM data2.input_null GROUP BY ... ORDER BY ...`

I'm trying to somehow find out/evaluate (initial_)query_id of parent's insert inside Materialized View's query.
It would be very helpful for monitoring/troubleshooting/statistics. 
If query_id or initial_query_id were known, it would have been possible to obtain a lot of additional information from system.query_log tables - both about origins of ETL data flow (IP addresses, http_user_agent) and about further destiny of this insert (whole picture of latencies within ClickHouse, additional checks that everything works as intended).

But all my attempts failed.
There are seemingly no inherent functions to receive initial_query_id that triggered MV during MV execution (however modern ClickHouse versions do display query's query_id in clickhouse-client).
I tried to fill initial_query_id via lookup into system.processes table, but the problem is that these are large inserts (500k-1M events) that are executed several seconds, and there are usually many simultaneous inserts of such kind. 
So Materialized View (when it is executed) can't find out which of existsing system.processes INSERT queries is its parent. 
`(SELECT arrayStringConcat(groupArray(initial_query_id), ',') FROM system.processes WHERE substr(query,1,37)='INSERT INTO data2.stage2_null_events') AS possible_query_ids,`
void registerFunctionCurrentDatabase(FunctionFactory &);
void registerFunctionCurrentUser(FunctionFactory &);
void registerFunctionHostName(FunctionFactory &);
void registerFunctionFQDN(FunctionFactory &);
void registerFunctionVisibleWidth(FunctionFactory &);
void registerFunctionToTypeName(FunctionFactory &);
void registerFunctionGetSizeOfEnumType(FunctionFactory &);
void registerFunctionBlockSerializedSize(FunctionFactory &);
void registerFunctionToColumnTypeName(FunctionFactory &);
void registerFunctionDumpColumnStructure(FunctionFactory &);
void registerFunctionDefaultValueOfArgumentType(FunctionFactory &);
void registerFunctionDefaultValueOfTypeName(FunctionFactory &);
void registerFunctionBlockSize(FunctionFactory &);
void registerFunctionBlockNumber(FunctionFactory &);
void registerFunctionRowNumberInBlock(FunctionFactory &);
void registerFunctionRowNumberInAllBlocks(FunctionFactory &);
void registerFunctionNeighbor(FunctionFactory &);
void registerFunctionSleep(FunctionFactory &);
void registerFunctionSleepEachRow(FunctionFactory &);
void registerFunctionMaterialize(FunctionFactory &);
void registerFunctionIgnore(FunctionFactory &);
void registerFunctionIndexHint(FunctionFactory &);
void registerFunctionIdentity(FunctionFactory &);
void registerFunctionArrayJoin(FunctionFactory &);
void registerFunctionReplicate(FunctionFactory &);