The only way to use this feature is to specify an empty database name in Distributed table definition, but then you get a warning:

```
CREATE TABLE `demo_loan_all` (...) ENGINE=Distributed(test_cluster_two_shards_different_databases, '', demo_loan_01568, cityHash64(id));

<Warning> StorageDistributed (demo_loan_all): Name of remote database is empty. Default database will be used implicitly.
```
{
    const auto & select = query_ptr->as<ASTSelectQuery &>();
    auto sharding_block_has = [&](const auto & exprs, size_t limit = SIZE_MAX) -> bool
    {
        size_t i = 0;
        for (auto & expr : exprs)
        {
            ++i;
            if (i > limit)
                break;
            auto id = expr->template as<ASTIdentifier>();
            if (!id)
                return false;
            
            if (!sharding_key_block.has(id->name()))
                return false;
        }
        return true;
    };
    
    
    
    if (select.group_by_with_totals || select.group_by_with_rollup || select.group_by_with_cube)
        return {};
    
    if (extremes)
        return {};