TEST_F(InternalUnpackBucketSplitMatchOnMetaAndRename, SplitsWhenEntireMatchIsOnMetaField) {
    auto unpack = DocumentSourceInternalUnpackBucket::createFromBsonInternal(
        fromjson("{$_internalUnpackBucket: { exclude: [], timeField: 'foo', metaField: 'myMeta', "
                 "bucketMaxSpanSeconds: 3600}}")
            .firstElement(),
        getExpCtx());
    auto matchToSplit = DocumentSourceMatch::create(
        fromjson("{$or: [{myMeta: {$gt: 1}}, {'myMeta.a': {$lt: 1}}]}"), getExpCtx());

    auto [metaOnlyMatch, remainingMatch] =
        dynamic_cast<DocumentSourceInternalUnpackBucket*>(unpack.get())
            ->splitMatchOnMetaAndRename(matchToSplit.get());

    // Can split and rename when the match is entirely on the metaField.
    ASSERT_TRUE(metaOnlyMatch);
    ASSERT_BSONOBJ_EQ(fromjson("{$or: [{meta: {$gt: 1}}, {'meta.a': {$lt: 1}}]}"),
                      metaOnlyMatch->getQuery());
    ASSERT_FALSE(remainingMatch);
}
TEST_F(InternalUnpackBucketSplitMatchOnMetaAndRename, SplitsWhenEntireMatchIsOnMetaField) {
    auto unpack = DocumentSourceInternalUnpackBucket::createFromBsonInternal(
        fromjson("{$_internalUnpackBucket: { exclude: [], timeField: 'foo', metaField: 'myMeta', "
                 "bucketMaxSpanSeconds: 3600}}")
            .firstElement(),
        getExpCtx());
    auto matchToSplit = DocumentSourceMatch::create(
        fromjson("{$or: [{myMeta: {$gt: 1}}, {'myMeta.a': {$lt: 1}}]}"), getExpCtx());

    auto [metaOnlyMatch, remainingMatch] =
        dynamic_cast<DocumentSourceInternalUnpackBucket*>(unpack.get())
            ->splitMatchOnMetaAndRename(matchToSplit.get());

     
    ASSERT_TRUE(metaOnlyMatch);
    ASSERT_BSONOBJ_EQ(fromjson("{$or: [{meta: {$gt: 1}}, {'meta.a': {$lt: 1}}]}"),
                      metaOnlyMatch->getQuery());
    ASSERT_FALSE(remainingMatch);
}