This is an automated email from the ASF dual-hosted git repository.

Gabriel39 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 66de8184040 [feature](mongodb) Complete M1 type coverage and safe scan 
pushdown (#70604)
66de8184040 is described below

commit 66de8184040f9b278bebd2d73303d9670230c46a
Author: Gabriel <[email protected]>
AuthorDate: Tue Nov 17 10:18:27 2026 +0800

    [feature](mongodb) Complete M1 type coverage and safe scan pushdown (#70604)
    
    ### Background
    
    The native MongoDB Catalog on master already provides single-cursor
    reads and first-release BSON SerDes. SQL filters and source projection
    have remained local, and the remaining M1 type and pushdown contracts
    need end-to-end qualification.
    
    ### What problem does this PR solve?
    
    Issue Number: #70251 (D04b and D05)
    Related PR: #70327 (native read path), #70456 (M0 acceptance), #70493
    (session read policies)
    PR Type: Feature
    
    Problem Summary:
    
    Complete the D04b qualification coverage and connect conservative
    predicate/LIKE candidates and column pruning to the native MongoDB
    reader. Every SQL predicate remains a Doris residual; the default strict
    type policy, strict SQL casts and standard views keep filtering local.
    This PR does not complete the separate D06 or later
    snapshot/parallel-scan work.
    
    ### Details
    
    - **Change map:** 456 added production lines, 1,221
    test/fixture/generated-result lines, and 47 documentation lines across
    19 files. The production changes comprise a connector-local translator
    and scan planning, three session controls, two optional descriptor
    fields, and native find options/validation. Most additions qualify types
    and compare execution modes.
    - **Scope:** D04b covers Decimal128 extremes, exact
    integer/floating-point behavior, UTC dates and scales, binary
    ownership/subtypes, missing/null, recursive arrays/structs, rollback and
    existing document limits. D05 covers typed scalar-root comparisons,
    positive IN/BETWEEN, scalar IS NOT NULL, safe AND/OR, necessary-literal
    LIKE candidates, root projection and time-series Date ranges.
    - **Design:** Candidates are classified conservatively as SUPERSET;
    unsupported expressions remain local, and the EXACT category is reserved
    for proven equivalence. No conjunct is consumed through either SPI path.
    CASTs are rejected before the neutral converter can erase them. The
    translator reconciles the schema/expression SPI date-scale and
    decimal-width representations, including FE's DECIMAL128 name. Native
    BSON is bounded and validated before client acquisition; views cannot
    receive a predicate/collation override. Complete root projection retains
    residual columns and scalar-ancestor errors.
    - **Usage:** Use `SET` or `SET_VAR` with
    `enable_mongodb_predicate_pushdown`, `enable_mongodb_like_pushdown` and
    `enable_mongodb_projection_pushdown`. Predicate candidates require the
    explicit catalog policy `mongodb.type_mismatch=null`.
    - **Default behavior:** All three switches default to true. The default
    `type_mismatch=error` policy preserves local filtering;
    `enable_strict_cast=true` and views also preserve local filtering.
    Source projection is eligible independently. DOUBLE/NaN comparisons,
    NOT/!=/NOT IN, mismatch-sensitive IS NULL, functions, casts, nested
    predicate paths and existing direct VARBINARY operator restrictions stay
    local. LIKE keeps the complete SQL residual. LIMIT, aggregation, sort,
    joins, snapshots and parallel scans are unchanged.
    - **Compatibility:** The connector SPI and stored schemas are unchanged.
    Descriptor fields 23/24 are optional; absent fields preserve the prior
    full scan. The touched descriptor is absent from the four supported
    release branches, so no field id is reused. Qualification uses matching
    FE/BE versions.
    
    ### Testing
    
    All testing below ran locally against MongoDB 8.0.20 with authentication
    enabled and an ASAN BE:
    
    - 64 MongoDB connector FE tests, 25 connector-session/forwarding tests,
    3 session read-policy tests and 55 BSON/native-reader BE tests passed
    (147 total).
    - All four MongoDB SQL suites passed: 4 suites, 0 failed, 0 fatal, 0
    skipped. This includes the existing native and M0 acceptance suites, the
    session read-policy suite and the new M1 suite.
    - The generated M1 output contains 40 identical sorted result pairs with
    predicate/LIKE/projection disabled and enabled. It covers precision,
    NULL/arrays, casts, collations, residual LIMIT, aggregates/joins, views
    and time-series reads. The completed Profile check reports
    `MongoRowsRead` of 10 with candidates disabled and 1 with them enabled.
    - Source profiling independently confirmed actual BSON int64, Decimal128
    and Date filters, projection, simple collection collation, and view
    reads without a collation override.
    - Full FE and ASAN BE builds passed on the integrated master base; the
    SQL suites use that matching built pair. Full FE Checkstyle and the
    final affected-core-file Checkstyle run passed with zero violations. All
    affected C/C++ files pass clang-format 16, build hygiene and clang-tidy.
    - Red/green checks reproduced missing candidate planning, acceptance of
    malformed BSON descriptors, missing strict-cast gating, command-budget
    gaps, schema/expression type representation gaps, and the false negative
    for ARRAY/JSON IS NOT NULL with null elements before the corresponding
    implementations.
    
    ### Release note
    
    Native MongoDB scans can prune source fields and apply conservative
    WHERE/LIKE candidates under the explicit null-on-type-mismatch policy.
    SQL residuals remain active, and default strict scans and views preserve
    local filtering. New session switches allow statement-level comparisons
    and disabling these optimizations.
    
    ### Check List (For Author)
    
    - Behavior changed: Yes (see Details).
    - Does this need documentation: Yes; the connector and fixture READMEs
    are updated here.
    - Pre-submission status: Ready. Local UT, authenticated SQL regression,
    builds and style/static checks passed; CI is pending.
    
    ### AI Disclosure
    
    - Tool: Codex (GPT-6).
    - Generated: Implementation, tests, fixture, documentation and this
    description.
    - Human review: Pending maintainer review.
---
 be/src/format_v2/table/mongodb_reader.cpp          |  65 +++-
 be/src/format_v2/table/mongodb_reader.h            |   4 +
 .../data_type_serde/data_type_serde_bson_test.cpp  | 127 +++++++
 be/test/format_v2/table/mongodb_reader_test.cpp    | 104 ++++++
 .../thirdparties/docker-compose/mongodb/README.md  |   8 +
 .../docker-compose/mongodb/init/03-m1-fixtures.js  |  44 +++
 .../docker-compose/mongodb/mongodb.yaml.tpl        |   1 +
 fe/fe-connector/fe-connector-mongodb/README.md     |  42 ++-
 .../connector/mongodb/MongoConnectorMetadata.java  |   6 +
 .../mongodb/MongoPredicateTranslator.java          | 299 +++++++++++++++++
 .../connector/mongodb/MongoScanPlanProvider.java   |  70 +++-
 .../doris/connector/mongodb/MongoMetadataTest.java |   8 +
 .../mongodb/MongoPredicateTranslatorTest.java      | 273 ++++++++++++++++
 .../doris/connector/mongodb/MongoScanPlanTest.java | 122 ++++++-
 .../java/org/apache/doris/qe/SessionVariable.java  |  15 +
 .../doris/connector/ConnectorSessionImplTest.java  |  28 ++
 gensrc/thrift/PlanNodes.thrift                     |   4 +
 .../external_table_p0/mongodb/test_mongodb_m1.out  | 363 +++++++++++++++++++++
 .../mongodb/test_mongodb_m1.groovy                 | 152 +++++++++
 19 files changed, 1724 insertions(+), 11 deletions(-)

diff --git a/be/src/format_v2/table/mongodb_reader.cpp 
b/be/src/format_v2/table/mongodb_reader.cpp
index cad5c054f03..726769f1e72 100644
--- a/be/src/format_v2/table/mongodb_reader.cpp
+++ b/be/src/format_v2/table/mongodb_reader.cpp
@@ -34,6 +34,7 @@
 #include "runtime/descriptors.h"
 #include "runtime/file_scan_profile.h"
 #include "runtime/runtime_state.h"
+#include "util/defer_op.h"
 
 namespace doris::format::mongodb {
 namespace {
@@ -124,6 +125,29 @@ Status acquire_pool(const TMongoScanDesc& d, 
std::shared_ptr<ClientPool>* result
     return Status::OK();
 }
 
+Status validate_pushdown_bson(const TMongoScanDesc& d) {
+    for (const auto* bytes : {d.__isset.filter_bson ? &d.filter_bson : nullptr,
+                              d.__isset.projection_bson ? &d.projection_bson : 
nullptr}) {
+        if (!bytes) {
+            continue;
+        }
+        bson_t view;
+        // A truncated/oversized RPC payload must fail before libmongoc reads 
it or acquires a lease.
+        if (bytes->size() > 1024 * 1024 ||
+            !bson_init_static(&view, reinterpret_cast<const 
uint8_t*>(bytes->data()),
+                              bytes->size()) ||
+            !bson_validate(&view, BSON_VALIDATE_NONE, nullptr)) {
+            return Status::InvalidArgument("Invalid MongoDB pushdown BSON 
descriptor");
+        }
+    }
+    // A stale or malformed FE plan must not bypass the strict-error or 
view-collation contracts.
+    if (d.__isset.filter_bson && (!d.type_mismatch_as_null || d.object_kind == 
"view")) {
+        return Status::InvalidArgument(
+                "MongoDB predicate pushdown is unavailable for strict scans or 
views");
+    }
+    return Status::OK();
+}
+
 Status mongo_error(const bson_error_t& error) {
     // Driver messages can contain URIs, credentials, commands, or source 
values.
     return Status::IOError("MongoDB command failed (domain={}, code={})", 
error.domain, error.code);
@@ -136,6 +160,7 @@ public:
         _cancelled = std::move(cancelled);
         _deadline = Clock::now() + std::chrono::milliseconds(d.timeout_ms);
         RETURN_IF_ERROR(check_deadline());
+        RETURN_IF_ERROR(validate_pushdown_bson(d));
         RETURN_IF_ERROR(acquire_pool(d, &_pool));
         while (!(_client = mongoc_client_pool_try_pop(_pool->pool.get()))) {
             RETURN_IF_ERROR(check_deadline());
@@ -157,14 +182,17 @@ public:
         RETURN_IF_ERROR(configure_mongodb_read_preference(_collection.get(), 
d.read_preference));
         bson_t filter = BSON_INITIALIZER;
         bson_t options = BSON_INITIALIZER;
+        Defer release_bson([&] {
+            bson_destroy(&options);
+            bson_destroy(&filter);
+        });
+        RETURN_IF_ERROR(build_mongodb_find_options(d, &filter, &options));
         BSON_APPEND_INT32(&options, "batchSize", d.batch_size);
         BSON_APPEND_INT64(&options, "maxTimeMS", remaining_ms());
         // Always query the public logical namespace: a view may change rows, 
names, and _id,
         // and time-series buckets are an internal storage representation.
         _cursor.reset(
                 mongoc_collection_find_with_opts(_collection.get(), &filter, 
&options, nullptr));
-        bson_destroy(&options);
-        bson_destroy(&filter);
         if (!_cursor) {
             return Status::IOError("MongoDB cursor initialization failed");
         }
@@ -292,6 +320,33 @@ Status 
configure_mongodb_read_preference(_mongoc_collection_t* collection,
     return Status::OK();
 }
 
+Status build_mongodb_find_options(const TMongoScanDesc& d, bson_t* filter, 
bson_t* options) {
+    RETURN_IF_ERROR(validate_pushdown_bson(d));
+    if (d.__isset.filter_bson) {
+        bson_t view;
+        bson_init_static(&view, reinterpret_cast<const 
uint8_t*>(d.filter_bson.data()),
+                         d.filter_bson.size());
+        if (!bson_concat(filter, &view)) {
+            return Status::InvalidArgument("MongoDB candidate filter exceeds 
BSON limits");
+        }
+        // Views cannot override their own collation and are rejected above. 
For example, the
+        // ordinary collection's case-insensitive default must not change SQL 
text = 'alpha'.
+        bson_t collation;
+        BSON_APPEND_DOCUMENT_BEGIN(options, "collation", &collation);
+        BSON_APPEND_UTF8(&collation, "locale", "simple");
+        bson_append_document_end(options, &collation);
+    }
+    if (d.__isset.projection_bson) {
+        bson_t view;
+        bson_init_static(&view, reinterpret_cast<const 
uint8_t*>(d.projection_bson.data()),
+                         d.projection_bson.size());
+        if (!BSON_APPEND_DOCUMENT(options, "projection", &view)) {
+            return Status::InvalidArgument("MongoDB projection exceeds BSON 
limits");
+        }
+    }
+    return Status::OK();
+}
+
 Status validate_mongodb_range(const TFileRangeDesc& range) {
     if (!range.__isset.table_format_params ||
         range.table_format_params.table_format_type != "mongodb" ||
@@ -313,7 +368,7 @@ Status validate_mongodb_range(const TFileRangeDesc& range) {
          d.read_concern != "available")) {
         return Status::InvalidArgument("Invalid or unsupported MongoDB native 
scan descriptor");
     }
-    return Status::OK();
+    return validate_pushdown_bson(d);
 }
 
 MongoFileReader::MongoFileReader(std::shared_ptr<io::FileSystemProperties>& 
properties,
@@ -451,8 +506,8 @@ Status MongoFileReader::_read_block(Block* block, size_t* 
rows, bool* eof) {
             }
             SCOPED_TIMER(_decode_time);
             BsonValueView root = BsonValueView::document(*document);
-            // Resource/structural failures apply to the entire document, 
outside the per-field
-            // mismatch-as-NULL policy, so projection cannot bypass the 
decoding limits.
+            // Validate every returned subtree before conversion. 
Resource/structural failures
+            // must not be swallowed by the per-field mismatch-as-NULL policy.
             RETURN_IF_ERROR(validate_bson_tree(root));
             // A later field can fail after earlier columns appended. Snapshot 
every column before
             // the first append so the failing source document contributes no 
partial Doris row.
diff --git a/be/src/format_v2/table/mongodb_reader.h 
b/be/src/format_v2/table/mongodb_reader.h
index db7a744378b..672344c3aa3 100644
--- a/be/src/format_v2/table/mongodb_reader.h
+++ b/be/src/format_v2/table/mongodb_reader.h
@@ -52,6 +52,10 @@ std::unique_ptr<MongoCursorStream> 
make_native_mongo_stream();
 using MongoStreamFactory = std::function<std::unique_ptr<MongoCursorStream>()>;
 // Validate the typed single-cursor contract and resource bounds before 
creating driver objects.
 Status validate_mongodb_range(const TFileRangeDesc& range);
+// Copy bounded typed BSON candidates/projection into caller-owned documents. 
Views retain their
+// source collation; collection candidates use simple collation. No network or 
client ownership.
+Status build_mongodb_find_options(const TMongoScanDesc& descriptor, _bson_t* 
filter,
+                                  _bson_t* options);
 // Apply the effective catalog mode while preserving URI tag sets and max 
staleness on the collection.
 Status configure_mongodb_read_preference(_mongoc_collection_t* collection,
                                          const std::string& preference);
diff --git a/be/test/core/data_type_serde/data_type_serde_bson_test.cpp 
b/be/test/core/data_type_serde/data_type_serde_bson_test.cpp
index 0810757d20e..c1bac37395f 100644
--- a/be/test/core/data_type_serde/data_type_serde_bson_test.cpp
+++ b/be/test/core/data_type_serde/data_type_serde_bson_test.cpp
@@ -566,4 +566,131 @@ TEST_F(BsonSerdeTest, 
DecimalStorageWidthsPreserveExactScaledValues) {
               static_cast<Int128>(1234500000000LL));
 }
 
+TEST_F(BsonSerdeTest, Decimal128ExtremesNeverRoundOrChangeEarlierRows) {
+    auto type = 
make_nullable(std::make_shared<DataTypeDecimal<TYPE_DECIMAL128I>>(38, 4));
+    auto column = type->create_column();
+    for (const auto& text :
+         {"9999999999999999999999999999999999", 
"-9999999999999999999999999999999999", "-0E+6111",
+          "1E-4", "123.4500000000000000000000000000000"}) {
+        ASSERT_TRUE(
+                read(type, *column, R"({"v":{"$numberDecimal":")" + 
std::string(text) + R"("}})")
+                        .ok());
+    }
+    for (const auto& text : {"1E+34", "1E-5", "1E-6176", "-NaN", "-Infinity"}) 
{
+        std::string json = R"({"v":{"$numberDecimal":")" + std::string(text) + 
R"("}})";
+        const auto before = column->size();
+        EXPECT_FALSE(read(type, *column, json).ok());
+        EXPECT_EQ(column->size(), before);
+        ASSERT_TRUE(read(type, *column, json, true).ok());
+        EXPECT_TRUE(assert_cast<const 
ColumnNullable&>(*column).is_null_at(before));
+    }
+    ASSERT_TRUE(read(type, *column, 
R"({"v":{"$numberDecimal":"1.0000"}})").ok());
+    const auto& data = assert_cast<const ColumnDecimal<TYPE_DECIMAL128I>&>(
+                               assert_cast<const 
ColumnNullable&>(*column).get_nested_column())
+                               .get_data();
+    EXPECT_EQ(data.back().value, 10000);
+}
+
+TEST_F(BsonSerdeTest, UtcDatetimeRangeBoundariesAreLossless) {
+    auto type = std::make_shared<DataTypeDateTimeV2>(3);
+    auto column = type->create_column();
+    ASSERT_TRUE(read(type, *column, 
R"({"v":{"$date":{"$numberLong":"-62135596800000"}}})").ok());
+    ASSERT_TRUE(read(type, *column, 
R"({"v":{"$date":{"$numberLong":"253402300799000"}}})").ok());
+    EXPECT_FALSE(read(type, *column, 
R"({"v":{"$date":{"$numberLong":"253402300800000"}}})").ok());
+    EXPECT_FALSE(
+            read(type, *column, 
R"({"v":{"$date":{"$numberLong":"-9223372036854775808"}}})").ok());
+    EXPECT_EQ(column->size(), 2);
+    auto packed = assert_cast<const ColumnDateTimeV2&>(*column).get_data()[1];
+    DateV2Value<DateTimeV2ValueType> value;
+    memcpy(&value, &packed, sizeof(value));
+    EXPECT_EQ(value.year(), 9999);
+    EXPECT_EQ(value.month(), 12);
+    EXPECT_EQ(value.day(), 31);
+}
+
+TEST_F(BsonSerdeTest, UtcDatetimeFractionalScaleNeverRounds) {
+    for (int scale : {0, 1, 2, 3, 6}) {
+        auto type = std::make_shared<DataTypeDateTimeV2>(scale);
+        auto column = type->create_column();
+        auto upper = read(type, *column, 
R"({"v":{"$date":{"$numberLong":"253402300799999"}}})");
+        EXPECT_EQ(upper.ok(), scale >= 3);
+        auto negative = read(type, *column, 
R"({"v":{"$date":{"$numberLong":"-1"}}})");
+        EXPECT_EQ(negative.ok(), scale >= 3);
+    }
+}
+
+TEST_F(BsonSerdeTest, FloatingPointSpecialValuesAndNarrowingKeepTheContract) {
+    auto type = std::make_shared<DataTypeFloat64>();
+    auto column = type->create_column();
+    for (const auto& text : {"NaN", "Infinity", "-Infinity", "-0.0"}) {
+        ASSERT_TRUE(read(type, *column, R"({"v":{"$numberDouble":")" + 
std::string(text) + R"("}})")
+                            .ok());
+    }
+    const auto& data = assert_cast<const ColumnFloat64&>(*column).get_data();
+    EXPECT_TRUE(std::isnan(data[0]));
+    EXPECT_EQ(data[1], std::numeric_limits<double>::infinity());
+    EXPECT_EQ(data[2], -std::numeric_limits<double>::infinity());
+    EXPECT_TRUE(std::signbit(data[3]));
+    auto narrow = make_nullable(std::make_shared<DataTypeFloat32>());
+    auto narrowed = narrow->create_column();
+    EXPECT_FALSE(read(narrow, *narrowed, R"({"v":0.1})").ok());
+    EXPECT_EQ(narrowed->size(), 0);
+    ASSERT_TRUE(read(narrow, *narrowed, R"({"v":0.1})", true).ok());
+    ASSERT_TRUE(read(narrow, *narrowed, R"({"v":1.5})").ok());
+    EXPECT_TRUE(assert_cast<const ColumnNullable&>(*narrowed).is_null_at(0));
+    EXPECT_FALSE(assert_cast<const ColumnNullable&>(*narrowed).is_null_at(1));
+}
+
+TEST_F(BsonSerdeTest, RecursiveStructArrayDecimalFailureRestoresEveryOffset) {
+    auto decimal = 
make_nullable(std::make_shared<DataTypeDecimal<TYPE_DECIMAL64>>(10, 2));
+    auto strings = make_nullable(
+            
std::make_shared<DataTypeArray>(make_nullable(std::make_shared<DataTypeString>())));
+    auto structure = make_nullable(std::make_shared<DataTypeStruct>(DataTypes 
{decimal, strings},
+                                                                    Strings 
{"amount", "tags"}));
+    auto type = make_nullable(std::make_shared<DataTypeArray>(structure));
+    auto column = type->create_column();
+    auto root = binding("v", {4});
+    auto element = binding("element", {3});
+    auto tags = binding("tags", {4});
+    tags.children = {binding("element", {2})};
+    element.children = {binding("amount", {19}), tags};
+    root.children = {element};
+    std::string valid = 
R"({"v":[{"tags":["a",null],"amount":{"$numberDecimal":"1.20"}},null,{}]})";
+    ASSERT_TRUE(read(type, *column, valid, root).ok());
+    const auto& array = assert_cast<const ColumnArray&>(
+            assert_cast<const ColumnNullable&>(*column).get_nested_column());
+    EXPECT_EQ(array.get_offsets().back(), 3);
+    std::string invalid =
+            
R"({"v":[{"amount":{"$numberDecimal":"2.00"},"tags":["new"]},{"amount":{"$numberDecimal":"1.234"}}]})";
+    EXPECT_FALSE(read(type, *column, invalid, root).ok());
+    EXPECT_EQ(column->size(), 1);
+    EXPECT_EQ(array.get_data().size(), 3);
+    ASSERT_TRUE(read(type, *column, invalid, root, true).ok());
+    EXPECT_TRUE(assert_cast<const ColumnNullable&>(*column).is_null_at(1));
+    EXPECT_EQ(array.get_data().size(), 3);
+    ASSERT_TRUE(read(type, *column, valid, root).ok());
+    EXPECT_EQ(array.get_offsets().back(), 6);
+    EXPECT_EQ(array.get_data().size(), 6);
+}
+
+TEST_F(BsonSerdeTest, BinarySubtypeTwoOwnsPayloadAndRejectsOtherSubtypes) {
+    auto type = make_nullable(std::make_shared<DataTypeVarbinary>());
+    auto column = type->create_column();
+    auto field = binding("v", {5});
+    field.subtype = 2;
+    ASSERT_TRUE(read(type, *column, 
R"({"v":{"$binary":{"base64":"AP+A","subType":"02"}}})", field)
+                        .ok());
+    EXPECT_EQ(assert_cast<const ColumnNullable&>(*column)
+                      .get_nested_column()
+                      .get_data_at(0)
+                      .to_string(),
+              std::string("\x00\xff\x80", 3));
+    EXPECT_FALSE(read(type, *column, 
R"({"v":{"$binary":{"base64":"AP+A","subType":"04"}}})", field)
+                         .ok());
+    EXPECT_EQ(column->size(), 1);
+    ASSERT_TRUE(
+            read(type, *column, 
R"({"v":{"$binary":{"base64":"","subType":"02"}}})", field).ok());
+    EXPECT_FALSE(assert_cast<const ColumnNullable&>(*column).is_null_at(1));
+}
+
 } // namespace doris
diff --git a/be/test/format_v2/table/mongodb_reader_test.cpp 
b/be/test/format_v2/table/mongodb_reader_test.cpp
index 31e7b4e8d99..4a91ff4d002 100644
--- a/be/test/format_v2/table/mongodb_reader_test.cpp
+++ b/be/test/format_v2/table/mongodb_reader_test.cpp
@@ -417,4 +417,108 @@ TEST(MongoNativeStreamTest, 
FailedConnectionReturnsErrorAndReleasesLeases) {
     }
 }
 
+TEST(MongoNativeStreamTest, MalformedPushdownBsonIsRejectedBeforeConnecting) {
+    for (bool projection : {false, true}) {
+        auto scan = range();
+        auto& d = scan.table_format_params.mongodb_params;
+        d.__set_type_mismatch_as_null(true);
+        if (projection) {
+            d.__set_projection_bson("invalid BSON");
+        } else {
+            d.__set_filter_bson("invalid BSON");
+        }
+        EXPECT_FALSE(validate_mongodb_range(scan).ok());
+    }
+}
+
+namespace {
+std::string bson_bytes(const bson_t& value) {
+    return {reinterpret_cast<const char*>(bson_get_data(&value)), value.len};
+}
+} // namespace
+
+TEST(MongoNativeStreamTest, TypedFindOptionsKeepDateIntegerAndProjectionBytes) 
{
+    auto d = range().table_format_params.mongodb_params;
+    d.__set_type_mismatch_as_null(true);
+    bson_t source = BSON_INITIALIZER;
+    bson_t bounds;
+    BSON_APPEND_DOCUMENT_BEGIN(&source, "observed", &bounds);
+    BSON_APPEND_DATE_TIME(&bounds, "$gte", -1);
+    bson_append_document_end(&source, &bounds);
+    BSON_APPEND_INT64(&source, "n", 9007199254740993LL);
+    d.__set_filter_bson(bson_bytes(source));
+    bson_destroy(&source);
+    bson_t projection = BSON_INITIALIZER;
+    BSON_APPEND_INT32(&projection, "observed", 1);
+    BSON_APPEND_INT32(&projection, "_id", 0);
+    d.__set_projection_bson(bson_bytes(projection));
+    bson_destroy(&projection);
+    bson_t filter = BSON_INITIALIZER;
+    bson_t options = BSON_INITIALIZER;
+    ASSERT_TRUE(build_mongodb_find_options(d, &filter, &options).ok());
+    EXPECT_EQ(bson_bytes(filter), d.filter_bson);
+    bson_iter_t it;
+    ASSERT_TRUE(bson_iter_init_find(&it, &filter, "n"));
+    ASSERT_EQ(bson_iter_type(&it), BSON_TYPE_INT64);
+    EXPECT_EQ(bson_iter_int64(&it), 9007199254740993LL);
+    ASSERT_TRUE(bson_iter_init_find(&it, &options, "projection"));
+    uint32_t length;
+    const uint8_t* bytes;
+    bson_iter_document(&it, &length, &bytes);
+    EXPECT_EQ(std::string(reinterpret_cast<const char*>(bytes), length), 
d.projection_bson);
+    ASSERT_TRUE(bson_iter_init_find(&it, &options, "collation"));
+    bson_t collation;
+    bson_iter_document(&it, &length, &bytes);
+    ASSERT_TRUE(bson_init_static(&collation, bytes, length));
+    ASSERT_TRUE(bson_iter_init_find(&it, &collation, "locale"));
+    EXPECT_STREQ(bson_iter_utf8(&it, nullptr), "simple");
+    bson_destroy(&filter);
+    bson_destroy(&options);
+}
+
+TEST(MongoNativeStreamTest, ViewProjectionNeverOverridesItsCollation) {
+    auto d = range().table_format_params.mongodb_params;
+    d.__set_object_kind("view");
+    bson_t projection = BSON_INITIALIZER;
+    BSON_APPEND_INT32(&projection, "value", 1);
+    d.__set_projection_bson(bson_bytes(projection));
+    bson_destroy(&projection);
+    bson_t filter = BSON_INITIALIZER;
+    bson_t options = BSON_INITIALIZER;
+    ASSERT_TRUE(build_mongodb_find_options(d, &filter, &options).ok());
+    bson_iter_t it;
+    EXPECT_FALSE(bson_iter_init_find(&it, &options, "collation"));
+    EXPECT_TRUE(bson_iter_init_find(&it, &options, "projection"));
+    bson_destroy(&filter);
+    bson_destroy(&options);
+}
+
+TEST(MongoNativeStreamTest, OldDescriptorsKeepEmptyFindOptions) {
+    auto d = range().table_format_params.mongodb_params;
+    bson_t filter = BSON_INITIALIZER;
+    bson_t options = BSON_INITIALIZER;
+    ASSERT_TRUE(build_mongodb_find_options(d, &filter, &options).ok());
+    EXPECT_TRUE(bson_empty(&filter));
+    EXPECT_TRUE(bson_empty(&options));
+    bson_destroy(&filter);
+    bson_destroy(&options);
+}
+
+TEST(MongoNativeStreamTest, 
UnsafeViewStrictAndOversizedDescriptorsAreRejected) {
+    auto scan = range();
+    auto& d = scan.table_format_params.mongodb_params;
+    bson_t candidate = BSON_INITIALIZER;
+    BSON_APPEND_INT32(&candidate, "value", 1);
+    d.__set_filter_bson(bson_bytes(candidate));
+    bson_destroy(&candidate);
+    EXPECT_FALSE(validate_mongodb_range(scan).ok());
+    d.__set_type_mismatch_as_null(true);
+    EXPECT_TRUE(validate_mongodb_range(scan).ok());
+    d.__set_object_kind("view");
+    EXPECT_FALSE(validate_mongodb_range(scan).ok());
+    d.__set_object_kind("collection");
+    d.__set_filter_bson(std::string(1024 * 1024 + 1, 'x'));
+    EXPECT_FALSE(validate_mongodb_range(scan).ok());
+}
+
 } // namespace doris::format::mongodb
diff --git a/docker/thirdparties/docker-compose/mongodb/README.md 
b/docker/thirdparties/docker-compose/mongodb/README.md
index 0de2bceca1c..6c8e6fb093a 100644
--- a/docker/thirdparties/docker-compose/mongodb/README.md
+++ b/docker/thirdparties/docker-compose/mongodb/README.md
@@ -114,3 +114,11 @@ closure and a subsequent successful read. Failpoints 
target this test's applicat
 name and are disabled in `finally` blocks. The catalog remains available for
 inspection. This is a focused lifecycle check; the release soak and 
topology/TLS
 matrices remain separate qualification work.
+
+`03-m1-fixtures.js` creates the independent `doris_mongodb_m1` database for
+`test_mongodb_m1`. The suite compares full sorted results with 
predicate/LIKE/projection
+switches disabled and enabled, and covers dirty scalar/array values, exact 
int64 and
+Decimal128 literals, UTC date ranges, nested rollback, subtype mismatches, 
source
+collation, strict errors, residuals, views, time-series scans and statement 
overrides.
+Its completed Profile check also verifies the selective candidate reduces 
`MongoRowsRead`
+from ten source documents to one.
diff --git a/docker/thirdparties/docker-compose/mongodb/init/03-m1-fixtures.js 
b/docker/thirdparties/docker-compose/mongodb/init/03-m1-fixtures.js
new file mode 100644
index 00000000000..448c06377db
--- /dev/null
+++ b/docker/thirdparties/docker-compose/mongodb/init/03-m1-fixtures.js
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+const m1 = db.getSiblingDB("doris_mongodb_m1");
+m1.dropDatabase();
+m1.records.insertMany([
+    {seq: NumberLong("1"), n: NumberLong("9007199254740993"), text: "alpha", 
active: true,
+     amount: NumberDecimal("123.4500"), observed: new Date(-1), bytes: 
BinData(0, "AP+A"),
+     nested: [{amount: NumberDecimal("1.20"), tags: ["a", null]}, null, {}]},
+    {seq: NumberLong("2"), n: NumberLong("-9007199254740993"), text: "a.b", 
active: false,
+     amount: NumberDecimal("-2.50"), observed: new Date(0), bytes: BinData(0, 
""), nested: []},
+    {seq: NumberLong("3"), n: null, text: null, active: null, amount: null, 
observed: null},
+    {seq: NumberLong("4"), text: ["alpha", "abc"], n: [NumberLong("7")], 
active: [true]},
+    {seq: NumberLong("5"), n: "20", text: "中文-é", active: true,
+     amount: NumberDecimal("1.234"), observed: new Date(253402300800000), 
bytes: BinData(128, "AP+A"),
+     nested: [{amount: NumberDecimal("2.00"), tags: ["first"]}, {amount: 
NumberDecimal("1.234")}]},
+    {seq: NumberLong("6"), n: NumberInt(20), text: "line\nalpha", active: 
false,
+     amount: NumberDecimal("1E-6176"), observed: new Date(253402300799999)},
+    {seq: NumberLong("7"), n: NumberLong("7"), text: "a%_b", active: true},
+    {seq: NumberLong("8"), n: NumberLong("8"), text: "alpha ", active: true},
+    {seq: NumberLong("9"), n: NumberLong("9"), text: "ALPHA", active: false},
+    {seq: NumberLong("10"), n: NumberLong("10"), text: "", active: false}
+]);
+// The valid predicate field must not hide a failure in another projected 
field under strict decoding.
+m1.dirty.insertMany([{seq: NumberLong("1"), n: NumberLong("10")}, {seq: 
NumberLong("2"), n: "bad"}]);
+m1.createCollection("collated", {collation: {locale: "en", strength: 2}});
+m1.collated.insertMany([{seq: NumberLong("1"), text: "alpha"}, {seq: 
NumberLong("2"), text: "ALPHA"},
+    {seq: NumberLong("3"), text: "alpha "}]);
+m1.paths.insertMany([{seq: NumberLong("1"), a: {b: NumberLong("10")}, 
"literal.dot": "a.b"},
+    {seq: NumberLong("2"), a: NumberLong("10"), "literal.dot": "value"}]);
diff --git a/docker/thirdparties/docker-compose/mongodb/mongodb.yaml.tpl 
b/docker/thirdparties/docker-compose/mongodb/mongodb.yaml.tpl
index f091e9ce59b..67874ea3215 100644
--- a/docker/thirdparties/docker-compose/mongodb/mongodb.yaml.tpl
+++ b/docker/thirdparties/docker-compose/mongodb/mongodb.yaml.tpl
@@ -60,6 +60,7 @@ services:
           && 
db.getSiblingDB('doris_mongodb_native').pattern_validator.countDocuments() === 1
           && 
db.getSiblingDB('doris_mongodb_native').dependency_validator.countDocuments() 
=== 1
           && 
db.getSiblingDB('doris_mongodb_native').nested_pattern_validator.countDocuments()
 === 1
+          && db.getSiblingDB('doris_mongodb_m1').records.countDocuments() === 
10
           && 
db.getSiblingDB('doris_mongodb_pagination').getCollectionNames().length === 140 
? 0 : 1);
       interval: 5s
       timeout: 5s
diff --git a/fe/fe-connector/fe-connector-mongodb/README.md 
b/fe/fe-connector/fe-connector-mongodb/README.md
index f81d1e08392..e021b2df6eb 100644
--- a/fe/fe-connector/fe-connector-mongodb/README.md
+++ b/fe/fe-connector/fe-connector-mongodb/README.md
@@ -94,9 +94,34 @@ and values outside the target range are rejected. No 
implicit string coercion oc
 ## Execution policy
 
 This implementation emits one split per logical namespace. The native cursor 
handles
-find/getMore batches. Projection is materialized locally, and every SQL filter,
-LIKE/REGEXP, join, aggregation, sort and LIMIT remains a Doris operation. Range
-splitting, predicate/LIMIT pushdown and shared snapshots are separate work.
+find/getMore batches. Safe source projection includes complete top-level roots 
required by
+output columns and every residual predicate; whole-document bindings and 
literal dot/dollar
+roots keep full documents. Whole roots preserve scalar-ancestor errors for 
nested mappings.
+
+`enable_mongodb_predicate_pushdown`, `enable_mongodb_like_pushdown`, and
+`enable_mongodb_projection_pushdown` default to `true` and support `SET` and 
`SET_VAR`.
+The predicate switch gates LIKE as well. Every predicate remains a Doris 
residual, and
+EXPLAIN reports `SUPERSET` or `UNSUPPORTED` without source values or 
credentials.
+
+Predicate candidates are enabled only with explicit 
`mongodb.type_mismatch=null`.
+The default `error` policy keeps filters local: filtering on one valid field 
could otherwise
+hide a conversion failure in another projected field, and validators do not 
prove historical
+data is clean. `enable_strict_cast=true` also keeps candidates local to 
preserve SQL
+conversion errors. Standard views keep SQL predicates local and retain their 
own collation.
+Collections and time-series scans with candidates use simple collation.
+
+Supported candidates include scalar-root integer/boolean/string/Decimal128 
comparisons,
+UTC BSON Date ranges (including time-series time fields), positive IN, 
BETWEEN, scalar IS NOT NULL,
+and safe AND/OR combinations. Numeric comparisons keep their BSON type and 
exact precision;
+integer mappings without source tags, DOUBLE/NaN, NOT/!=/NOT IN, IS NULL under 
mismatch-to-NULL,
+functions, CAST/TRY_CAST, and nested/array paths remain local. An OR requires 
a safe candidate
+for every arm. LIKE sends an escaped required literal substring as a 
conservative regex;
+wildcard-only, ambiguous escapes, NUL and REGEXP stay local. Doris always 
evaluates the full
+LIKE pattern, including anchors, wildcards, Unicode and newline rules.
+
+Join, aggregation, sort and LIMIT remain Doris operations. Range splitting, 
LIMIT pushdown
+and shared snapshots are separate work. Use matching FE/BE versions; the new 
optional BSON
+filter/projection fields preserve the single-cursor descriptor layout.
 
 `batch_size` and `query_timeout` are session variables. The following session 
variables
 also support statement-level `SET_VAR` hints; values are case-insensitive:
@@ -164,3 +189,14 @@ in `be/test/format_v2/table/mongodb_reader_test.cpp`. The 
regression suites
 fixture under `docker/thirdparties/docker-compose/mongodb/`, enabled with
 `enableMongoDBTest`, `externalEnvIp`, `mongodb_port`, `mongodb_user`, and
 `mongodb_password` regression settings.
+
+The M1 suite `test_mongodb_m1` uses `03-m1-fixtures.js` and compares predicate,
+LIKE and projection switches on/off over large integers, decimals, UTC dates,
+missing/null/malformed values, arrays, nested structs, binary subtypes, 
collations,
+views and time-series data. It also verifies strict error behavior, CAST/OR 
residuals,
+LIMIT, statement-switch restoration and EXPLAIN. A completed Profile check 
verifies
+`MongoRowsRead` changes from ten source documents to one for a selective 
candidate.
+First-release typed mappings support
+DECIMAL precision up to 38 and DATETIME scale 0..6 with no rounding; MAP, 
VARIANT,
+implicit numeric/string conversions and other unlisted target types are 
unsupported.
+Use JSON canonical Extended JSON or raw BSON to retain unsupported BSON tags.
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoConnectorMetadata.java
 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoConnectorMetadata.java
index d224b172989..b1585dd7e99 100644
--- 
a/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoConnectorMetadata.java
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoConnectorMetadata.java
@@ -47,6 +47,12 @@ final class MongoConnectorMetadata implements 
ConnectorMetadata {
         this.properties = properties;
     }
 
+    @Override
+    public boolean supportsCastPredicatePushdown(ConnectorSession session) {
+        // The neutral converter erases CAST. Accept predicates only through 
the CAST-filtered scan path.
+        return false;
+    }
+
     @Override
     public List<String> listDatabaseNames(ConnectorSession session) {
         return client.databases();
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoPredicateTranslator.java
 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoPredicateTranslator.java
new file mode 100644
index 00000000000..9f99c2622fb
--- /dev/null
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoPredicateTranslator.java
@@ -0,0 +1,299 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.mongodb;
+
+import org.apache.doris.connector.spi.ConnectorType;
+import org.apache.doris.connector.spi.pushdown.ConnectorAnd;
+import org.apache.doris.connector.spi.pushdown.ConnectorBetween;
+import org.apache.doris.connector.spi.pushdown.ConnectorColumnRef;
+import org.apache.doris.connector.spi.pushdown.ConnectorComparison;
+import org.apache.doris.connector.spi.pushdown.ConnectorExpression;
+import org.apache.doris.connector.spi.pushdown.ConnectorIn;
+import org.apache.doris.connector.spi.pushdown.ConnectorIsNull;
+import org.apache.doris.connector.spi.pushdown.ConnectorLike;
+import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
+import org.apache.doris.connector.spi.pushdown.ConnectorOr;
+
+import org.bson.Document;
+import org.bson.types.Decimal128;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/** Candidate filters only: the scan provider never consumes the original 
Doris predicates. */
+final class MongoPredicateTranslator {
+    enum Kind { EXACT, SUPERSET, UNSUPPORTED }
+
+    record Result(Kind kind, Document filter) {
+        static Result unsupported() {
+            return new Result(Kind.UNSUPPORTED, new Document());
+        }
+    }
+
+    private static final int MAX_TERMS = 1024;
+    private static final int MAX_DEPTH = 64;
+    private final Map<String, MongoSchema.Binding> bindings;
+    private final boolean like;
+    private int terms;
+
+    MongoPredicateTranslator(MongoSchema schema, boolean like) {
+        bindings = 
schema.getBindings().stream().collect(Collectors.toMap(MongoSchema.Binding::getName,
 b -> b));
+        this.like = like;
+    }
+
+    Result translate(ConnectorExpression expression) {
+        terms = 0;
+        return translate(expression, 0);
+    }
+
+    private Result translate(ConnectorExpression expression, int depth) {
+        if (depth > MAX_DEPTH || ++terms > MAX_TERMS) {
+            return Result.unsupported();
+        }
+        if (expression instanceof ConnectorAnd || expression instanceof 
ConnectorOr) {
+            boolean and = expression instanceof ConnectorAnd;
+            List<Document> filters = new ArrayList<>();
+            boolean exact = true;
+            for (ConnectorExpression child : expression.getChildren()) {
+                Result result = translate(child, depth + 1);
+                if (result.kind() == Kind.UNSUPPORTED) {
+                    if (!and) {
+                        // Dropping even one OR arm loses rows; AND can keep 
independently safe candidates.
+                        return Result.unsupported();
+                    }
+                    exact = false;
+                } else {
+                    filters.add(result.filter());
+                    exact &= result.kind() == Kind.EXACT;
+                }
+            }
+            return filters.isEmpty() ? Result.unsupported()
+                    : new Result(exact ? Kind.EXACT : Kind.SUPERSET,
+                            new Document(and ? "$and" : "$or", filters));
+        }
+        if (expression instanceof ConnectorComparison comparison) {
+            ConnectorExpression column = comparison.getLeft();
+            ConnectorExpression constant = comparison.getRight();
+            String operator = switch (comparison.getOperator()) {
+                case EQ, EQ_FOR_NULL -> "$eq";
+                case GT -> "$gt";
+                case GE -> "$gte";
+                case LT -> "$lt";
+                case LE -> "$lte";
+                default -> null;
+            };
+            if (operator == null) {
+                return Result.unsupported();
+            }
+            if (column instanceof ConnectorLiteral && constant instanceof 
ConnectorColumnRef) {
+                ConnectorExpression tmp = column;
+                column = constant;
+                constant = tmp;
+                operator = switch (operator) {
+                    case "$gt" -> "$lt";
+                    case "$gte" -> "$lte";
+                    case "$lt" -> "$gt";
+                    case "$lte" -> "$gte";
+                    default -> operator;
+                };
+            }
+            MongoSchema.Binding binding = binding(column);
+            if (binding == null || !(constant instanceof ConnectorLiteral 
literal)) {
+                return Result.unsupported();
+            }
+            Object value = typedValue(binding, literal);
+            return value == null ? Result.unsupported() : candidate(binding, 
operator, value);
+        }
+        if (expression instanceof ConnectorBetween between) {
+            return translate(new ConnectorAnd(List.of(
+                    new ConnectorComparison(ConnectorComparison.Operator.GE, 
between.getValue(), between.getLower()),
+                    new ConnectorComparison(ConnectorComparison.Operator.LE, 
between.getValue(), between.getUpper()))),
+                    depth + 1);
+        }
+        if (expression instanceof ConnectorIn in) {
+            MongoSchema.Binding binding = binding(in.getValue());
+            if (in.isNegated() || binding == null || in.getInList().isEmpty()
+                    || in.getInList().size() > MAX_TERMS) {
+                return Result.unsupported();
+            }
+            List<Object> values = new ArrayList<>();
+            for (ConnectorExpression item : in.getInList()) {
+                if (!(item instanceof ConnectorLiteral literal)) {
+                    return Result.unsupported();
+                }
+                // NULL contributes no TRUE arm to a positive IN; NOT IN 
deliberately stays local.
+                if (literal.isNull()) {
+                    continue;
+                }
+                Object value = typedValue(binding, literal);
+                if (value == null) {
+                    return Result.unsupported();
+                }
+                values.add(value);
+            }
+            return candidate(binding, "$in", values);
+        }
+        if (expression instanceof ConnectorIsNull isNull && 
isNull.isNegated()) {
+            MongoSchema.Binding binding = binding(isNull.getOperand());
+            if (binding == null || !Set.of("BOOLEAN", "TINYINT", "SMALLINT", 
"INT", "BIGINT", "LARGEINT",
+                    "FLOAT", "DOUBLE", "STRING", "VARBINARY", "DATETIMEV2", 
"DECIMALV3")
+                    .contains(binding.column().getType().getTypeName())) {
+                return Result.unsupported();
+            }
+            // MongoDB's $ne:null rejects arrays containing null. ARRAY[NULL] 
(or JSON [null])
+            // is a non-NULL SQL value, so complex targets must keep this 
predicate entirely local.
+            return candidate(binding, "$ne", null);
+        }
+        if (expression instanceof ConnectorLike predicate && like
+                && predicate.getOperator() == ConnectorLike.Operator.LIKE
+                && predicate.getPattern() instanceof ConnectorLiteral literal
+                && literal.getValue() instanceof String pattern) {
+            MongoSchema.Binding binding = binding(predicate.getValue());
+            if (binding == null || 
!"STRING".equals(binding.column().getType().getTypeName())) {
+                return Result.unsupported();
+            }
+            String regex = requiredLikeLiteral(pattern);
+            return regex == null ? Result.unsupported() : candidate(binding, 
"$regex", regex);
+        }
+        return Result.unsupported();
+    }
+
+    private MongoSchema.Binding binding(ConnectorExpression expression) {
+        if (!(expression instanceof ConnectorColumnRef ref)) {
+            return null;
+        }
+        MongoSchema.Binding binding = bindings.get(ref.getColumnName());
+        // A dotted MongoDB path traverses arrays implicitly, unlike the 
decoder. Start with scalar roots.
+        return binding != null && binding.getPath().size() == 1 && 
safePath(binding.getPath().get(0))
+                && matchesReferenceType(binding.column().getType(), 
ref.getType()) ? binding : null;
+    }
+
+    private static boolean matchesReferenceType(ConnectorType schema, 
ConnectorType expression) {
+        if (schema.equals(expression)) {
+            return true;
+        }
+        // The schema SPI stores DATETIME scale in precision; the expression 
SPI uses scale.
+        // For example, DATETIME(3) arrives as DATETIMEV2(-1,3), not the 
schema's (3,0).
+        if ("DATETIMEV2".equals(schema.getTypeName()) && 
"DATETIMEV2".equals(expression.getTypeName())) {
+            return schema.getPrecision() == Math.max(0, expression.getScale());
+        }
+        // Decimal expressions name their physical width after schema 
conversion (e.g. DECIMAL128).
+        return "DECIMALV3".equals(schema.getTypeName())
+                && Set.of("DECIMAL32", "DECIMAL64", "DECIMAL128", 
"DECIMAL256").contains(expression.getTypeName())
+                && schema.getPrecision() == expression.getPrecision() && 
schema.getScale() == expression.getScale();
+    }
+
+    static boolean safePath(String segment) {
+        return !segment.isEmpty() && !segment.contains(".") && 
!segment.contains("$") && segment.indexOf(0) < 0;
+    }
+
+    private static Result candidate(MongoSchema.Binding binding, String 
operator, Object value) {
+        // MongoDB may also match arrays or other numeric tags. 
NULL-on-mismatch and the residual
+        // discard those extra rows; no scalar guarantee is inferred from a 
validator on historical data.
+        return new Result(Kind.SUPERSET, new 
Document(binding.getPath().get(0), new Document(operator, value)));
+    }
+
+    private static Object typedValue(MongoSchema.Binding binding, 
ConnectorLiteral literal) {
+        if (literal.isNull()) {
+            return null;
+        }
+        Document mapping = binding.toDocument();
+        List<Integer> tags = mapping.getList("bson_types", 
Integer.class).stream().filter(t -> t != 10).toList();
+        String type = binding.column().getType().getTypeName();
+        Object value = literal.getValue();
+        if (value instanceof String text && text.length() > 65536) {
+            return null;
+        }
+        if (Set.of("TINYINT", "SMALLINT", "INT", "BIGINT", 
"LARGEINT").contains(type)
+                && !tags.isEmpty() && tags.stream().allMatch(t -> t == 16 || t 
== 18)
+                && value instanceof Long) {
+            return value;
+        }
+        if ("BOOLEAN".equals(type) && value instanceof Boolean) {
+            return value;
+        }
+        if ("STRING".equals(type) && value instanceof String && ((String) 
value).indexOf(0) < 0) {
+            return value;
+        }
+        if ("DATETIMEV2".equals(type) && value instanceof LocalDateTime 
datetime
+                && datetime.getNano() % 1000000 == 0) {
+            // BSON Date uses UTC epoch milliseconds regardless of the Doris 
session timezone.
+            return Date.from(datetime.toInstant(ZoneOffset.UTC));
+        }
+        if ("BIGINT".equals(type) && tags.equals(List.of(9)) && value 
instanceof Long millis) {
+            return new Date(millis);
+        }
+        if ("DECIMALV3".equals(type) && (value instanceof BigDecimal || value 
instanceof Long)) {
+            try {
+                return new Decimal128(value instanceof BigDecimal
+                        ? (BigDecimal) value : BigDecimal.valueOf((Long) 
value));
+            } catch (NumberFormatException | ArithmeticException e) {
+                return null;
+            }
+        }
+        // DOUBLE/NaN comparisons and implicit coercions have no verified 
cross-engine contract.
+        return null;
+    }
+
+    static String requiredLikeLiteral(String pattern) {
+        if (pattern.length() > 4096 || pattern.indexOf(0) >= 0) {
+            return null;
+        }
+        StringBuilder chunk = new StringBuilder();
+        String longest = "";
+        for (int i = 0; i < pattern.length(); i++) {
+            char c = pattern.charAt(i);
+            if (c == '\\') {
+                if (++i == pattern.length() || 
"%_\\".indexOf(pattern.charAt(i)) < 0) {
+                    return null;
+                }
+                chunk.append(pattern.charAt(i));
+            } else if (c == '%' || c == '_') {
+                if (chunk.length() > longest.length()) {
+                    longest = chunk.toString();
+                }
+                chunk.setLength(0);
+            } else {
+                chunk.append(c);
+            }
+        }
+        if (chunk.length() > longest.length()) {
+            longest = chunk.toString();
+        }
+        if (longest.isEmpty()) {
+            return null;
+        }
+        StringBuilder regex = new StringBuilder();
+        for (int i = 0; i < longest.length(); i++) {
+            char c = longest.charAt(i);
+            if ("\\.^$|?*+()[]{}".indexOf(c) >= 0) {
+                regex.append('\\');
+            }
+            regex.append(c);
+        }
+        // A required literal substring avoids PCRE2/RE2 wildcard, newline and 
Unicode-width differences.
+        return regex.toString();
+    }
+}
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoScanPlanProvider.java
 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoScanPlanProvider.java
index da9a76387fc..2dd345855b4 100644
--- 
a/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoScanPlanProvider.java
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/main/java/org/apache/doris/connector/mongodb/MongoScanPlanProvider.java
@@ -26,6 +26,9 @@ import org.apache.doris.connector.spi.scan.ConnectorScanRange;
 import org.apache.doris.connector.spi.scan.ConnectorScanRequest;
 import org.apache.doris.thrift.TMongoScanDesc;
 
+import org.bson.Document;
+
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
@@ -72,6 +75,14 @@ final class MongoScanPlanProvider implements 
ConnectorScanPlanProvider {
         
d.setServerSelectionTimeoutMs(properties.getServerSelectionTimeoutMs());
         d.setSocketTimeoutMs(properties.getSocketTimeoutMs());
         d.setPoolMaxClients(properties.getPoolMaxClients());
+        MongoPredicateTranslator.Result predicate = predicate(session, handle, 
request.getFilter());
+        if (predicate.kind() != MongoPredicateTranslator.Kind.UNSUPPORTED) {
+            d.setFilterBson(encode(predicate.filter()));
+        }
+        Document projection = projection(session, handle, 
request.getColumns());
+        if (!projection.isEmpty()) {
+            d.setProjectionBson(encode(projection));
+        }
         // One cursor owns the entire logical namespace. Filters and LIMIT 
remain Doris residuals.
         return List.of(new MongoScanRange(d));
     }
@@ -92,8 +103,13 @@ final class MongoScanPlanProvider implements 
ConnectorScanPlanProvider {
     public Map<String, String> getScanNodeProperties(ConnectorSession session, 
ConnectorTableHandle handle,
             List<ConnectorColumnHandle> columns, Optional<ConnectorExpression> 
filter) {
         MongoTableHandle table = (MongoTableHandle) handle;
-        return Map.of("object_kind", table.getObjectKind(), "schema_source", 
table.getSchema().getSource(),
-                "schema_version", table.getSchema().getVersion());
+        Map<String, String> result = new LinkedHashMap<>();
+        result.put("object_kind", table.getObjectKind());
+        result.put("schema_source", table.getSchema().getSource());
+        result.put("schema_version", table.getSchema().getVersion());
+        result.put("predicate_pushdown", predicate(session, table, 
filter).kind().name());
+        result.put("projection_pushdown", projection(session, table, 
columns).isEmpty() ? "false" : "true");
+        return result;
     }
 
     @Override
@@ -101,6 +117,56 @@ final class MongoScanPlanProvider implements 
ConnectorScanPlanProvider {
         output.append(prefix).append("MongoDB object: 
").append(nodeProperties.get("object_kind"))
                 .append("; schema: 
").append(nodeProperties.get("schema_source"))
                 .append("; version: 
").append(nodeProperties.get("schema_version")).append("\n");
+        output.append(prefix).append("MongoDB predicate: 
").append(nodeProperties.get("predicate_pushdown"))
+                .append("; residual: retained; projection: 
").append(nodeProperties.get("projection_pushdown"))
+                .append("\n");
+    }
+
+    private MongoPredicateTranslator.Result predicate(ConnectorSession 
session, MongoTableHandle table,
+            Optional<ConnectorExpression> filter) {
+        // Even a predicate on a valid field can hide a strict decode failure 
in another projected field.
+        // A validator does not validate historical rows, so strict scans and 
views keep every filter local.
+        if (!"null".equals(properties.getTypeMismatch()) || 
"view".equals(table.getObjectKind())
+                || 
Boolean.parseBoolean(session.getSessionProperties().getOrDefault("enable_strict_cast",
 "false"))
+                || !enabled(session, "enable_mongodb_predicate_pushdown") || 
filter.isEmpty()) {
+            return MongoPredicateTranslator.Result.unsupported();
+        }
+        var result = new MongoPredicateTranslator(table.getSchema(), 
enabled(session, "enable_mongodb_like_pushdown"))
+                .translate(filter.get());
+        return encode(result.filter()).length <= 1024 * 1024
+                ? result : MongoPredicateTranslator.Result.unsupported();
+    }
+
+    private static Document projection(ConnectorSession session, 
MongoTableHandle table,
+            List<ConnectorColumnHandle> columns) {
+        if (!enabled(session, "enable_mongodb_projection_pushdown")) {
+            return new Document();
+        }
+        Document result = new Document();
+        for (ConnectorColumnHandle column : columns) {
+            Document binding = Document.parse(((MongoColumnHandle) 
column).getBindingJson());
+            List<String> path = binding.getList("path", String.class);
+            if (!"".equals(binding.getString("special")) || path.isEmpty()
+                    || !MongoPredicateTranslator.safePath(path.get(0))) {
+                return new Document();
+            }
+            // Project the complete root: {a:1} at [a,b] must remain a path 
error, not become missing.
+            result.put(path.get(0), 1);
+        }
+        // _id alone is an inclusion projection for COUNT(*) and preserves one 
result per document.
+        result.put("_id", result.isEmpty() || result.containsKey("_id") ? 1 : 
0);
+        return result;
+    }
+
+    private static boolean enabled(ConnectorSession session, String name) {
+        return 
Boolean.parseBoolean(session.getSessionProperties().getOrDefault(name, "true"));
+    }
+
+    private static byte[] encode(Document document) {
+        org.bson.io.BasicOutputBuffer buffer = new 
org.bson.io.BasicOutputBuffer();
+        new org.bson.codecs.DocumentCodec().encode(new 
org.bson.BsonBinaryWriter(buffer), document,
+                org.bson.codecs.EncoderContext.builder().build());
+        return buffer.toByteArray();
     }
 
 }
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoMetadataTest.java
 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoMetadataTest.java
index 1de5c718439..f680f546db2 100644
--- 
a/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoMetadataTest.java
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoMetadataTest.java
@@ -123,4 +123,12 @@ class MongoMetadataTest {
             Assertions.assertEquals(handle.getSchema().getColumns(), 
restored.getSchema().getColumns());
         }
     }
+
+    @Test
+    void castPredicatesCannotEnterTheCastErasingApplyFilterPath() {
+        var metadata = metadata(new RecordingClient());
+        Assertions.assertFalse(metadata.supportsCastPredicatePushdown(null));
+        Assertions.assertTrue(metadata.applyFilter(null, null, 
null).isEmpty());
+    }
+
 }
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoPredicateTranslatorTest.java
 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoPredicateTranslatorTest.java
new file mode 100644
index 00000000000..00f7b73bc49
--- /dev/null
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoPredicateTranslatorTest.java
@@ -0,0 +1,273 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.mongodb;
+
+import org.apache.doris.connector.spi.ConnectorType;
+import org.apache.doris.connector.spi.pushdown.ConnectorAnd;
+import org.apache.doris.connector.spi.pushdown.ConnectorBetween;
+import org.apache.doris.connector.spi.pushdown.ConnectorColumnRef;
+import org.apache.doris.connector.spi.pushdown.ConnectorComparison;
+import org.apache.doris.connector.spi.pushdown.ConnectorExpression;
+import org.apache.doris.connector.spi.pushdown.ConnectorIn;
+import org.apache.doris.connector.spi.pushdown.ConnectorIsNull;
+import org.apache.doris.connector.spi.pushdown.ConnectorLike;
+import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
+import org.apache.doris.connector.spi.pushdown.ConnectorNot;
+import org.apache.doris.connector.spi.pushdown.ConnectorOr;
+
+import org.bson.Document;
+import org.bson.types.Decimal128;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+class MongoPredicateTranslatorTest {
+    private MongoSchema schema(String name, List<String> path, String type, 
List<String> tags) {
+        Document column = new Document("name", name).append("path", 
path).append("doris_type", type)
+                .append("bson_types", tags);
+        var properties = MongoCatalogProperties.of(Map.of("mongodb.uri", 
"mongodb://localhost:27017",
+                "mongodb.schema", new Document("sample.records", new 
Document("columns", List.of(column))).toJson()));
+        return MongoSchema.resolve("sample.records", new Document("type", 
"collection"), properties);
+    }
+
+    private MongoSchema schema(String type, String... tags) {
+        return schema("v", List.of("Source"), type, List.of(tags));
+    }
+
+    private ConnectorColumnRef column(MongoSchema schema) {
+        return new ConnectorColumnRef("v", 
schema.getBindings().get(0).column().getType());
+    }
+
+    private ConnectorExpression comparison(MongoSchema schema, 
ConnectorComparison.Operator op,
+            ConnectorLiteral value) {
+        return new ConnectorComparison(op, column(schema), value);
+    }
+
+    private MongoPredicateTranslator.Result translate(MongoSchema schema, 
ConnectorExpression expression) {
+        return new MongoPredicateTranslator(schema, 
true).translate(expression);
+    }
+
+    @Test
+    void integerComparisonPreservesLongAboveDoublePrecisionAndSourceCase() {
+        var schema = schema("BIGINT", "long", "null");
+        long value = 9007199254740993L;
+        var result = translate(schema, comparison(schema, 
ConnectorComparison.Operator.GE, ConnectorLiteral.ofLong(value)));
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET, 
result.kind());
+        Assertions.assertEquals(value, result.filter().get("Source", 
Document.class).get("$gte"));
+    }
+
+    @Test
+    void reversedComparisonReversesTheRange() {
+        var schema = schema("BIGINT", "long");
+        var expression = new 
ConnectorComparison(ConnectorComparison.Operator.LT,
+                ConnectorLiteral.ofLong(7), column(schema));
+        Assertions.assertEquals(new Document("Source", new Document("$gt", 
7L)),
+                translate(schema, expression).filter());
+    }
+
+    @Test
+    void dateRangeUsesBsonDateInUtcAtNegativeEpoch() {
+        var schema = schema("DATETIME(3)", "date");
+        var instant = LocalDateTime.of(1969, 12, 31, 23, 59, 59, 999000000);
+        var result = translate(schema, comparison(schema, 
ConnectorComparison.Operator.GE,
+                ConnectorLiteral.ofDatetime(instant)));
+        Assertions.assertEquals(new Date(-1), result.filter().get("Source", 
Document.class).get("$gte"));
+        Assertions.assertEquals(-1, 
instant.toInstant(ZoneOffset.UTC).toEpochMilli());
+    }
+
+    @Test
+    void dateConstantsCannotLoseSubMillisecondPrecision() {
+        var schema = schema("DATETIME(6)", "date");
+        var value = ConnectorLiteral.ofDatetime(LocalDateTime.of(2024, 1, 1, 
0, 0, 0, 1000));
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                translate(schema, comparison(schema, 
ConnectorComparison.Operator.EQ, value)).kind());
+    }
+
+    @Test
+    void explicitEpochBindingUsesDateInsteadOfAnIntegerQuery() {
+        var schema = schema("BIGINT", "date");
+        var result = translate(schema, comparison(schema, 
ConnectorComparison.Operator.LT, ConnectorLiteral.ofLong(1)));
+        Assertions.assertEquals(new Date(1), result.filter().get("Source", 
Document.class).get("$lt"));
+    }
+
+    @Test
+    void decimalLiteralRemainsDecimal128WithoutDoubleConversion() {
+        var schema = schema("DECIMAL(38,10)", "decimal");
+        var value = new BigDecimal("9007199254740993.0000000001");
+        var result = translate(schema, comparison(schema, 
ConnectorComparison.Operator.EQ,
+                ConnectorLiteral.ofDecimal(value, 38, 10)));
+        Assertions.assertEquals(new Decimal128(value), 
result.filter().get("Source", Document.class).get("$eq"));
+    }
+
+    @Test
+    void inDropsNullArmsButNeverRewritesNotIn() {
+        var schema = schema("INT", "int");
+        var values = List.<ConnectorExpression>of(ConnectorLiteral.ofLong(1), 
ConnectorLiteral.ofNull(ConnectorType.of("INT")));
+        Assertions.assertEquals(new Document("Source", new Document("$in", 
List.of(1L))),
+                translate(schema, new ConnectorIn(column(schema), values, 
false)).filter());
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                translate(schema, new ConnectorIn(column(schema), values, 
true)).kind());
+    }
+
+    @Test
+    void betweenKeepsBothBoundsWithoutOverwritingTheSameField() {
+        var schema = schema("INT", "int");
+        var result = translate(schema, new ConnectorBetween(column(schema),
+                ConnectorLiteral.ofLong(1), ConnectorLiteral.ofLong(3)));
+        Assertions.assertEquals(2, result.filter().getList("$and", 
Document.class).size());
+    }
+
+    @Test
+    void andCanUseOneCandidateButOrRequiresEveryArm() {
+        var schema = schema("BIGINT", "long");
+        var supported = comparison(schema, ConnectorComparison.Operator.EQ, 
ConnectorLiteral.ofLong(1));
+        var unsupported = new ConnectorNot(supported);
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET,
+                translate(schema, new ConnectorAnd(List.of(supported, 
unsupported))).kind());
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                translate(schema, new ConnectorOr(List.of(supported, 
unsupported))).kind());
+        Assertions.assertEquals(2, translate(schema, new 
ConnectorOr(List.of(supported, supported)))
+                .filter().getList("$or", Document.class).size());
+    }
+
+    @Test
+    void nullOnMismatchMakesIsNullUnsafeButIsNotNullHasAValidSuperset() {
+        var schema = schema("TINYINT", "int");
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                translate(schema, new ConnectorIsNull(column(schema), 
false)).kind());
+        Assertions.assertEquals(new Document("Source", new Document("$ne", 
null)),
+                translate(schema, new ConnectorIsNull(column(schema), 
true)).filter());
+    }
+
+    @Test
+    void nullSafeEqualityDoesNotConfuseNonNullWithIsNull() {
+        var schema = schema("INT", "int");
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET, 
translate(schema,
+                comparison(schema, ConnectorComparison.Operator.EQ_FOR_NULL, 
ConnectorLiteral.ofLong(3))).kind());
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                comparison(schema, ConnectorComparison.Operator.EQ_FOR_NULL,
+                        
ConnectorLiteral.ofNull(ConnectorType.of("INT")))).kind());
+    }
+
+    @Test
+    void functionsFloatAndImplicitStringNumericCoercionStayLocal() {
+        for (String type : List.of("DOUBLE", "STRING")) {
+            var schema = schema(type);
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                    translate(schema, comparison(schema, 
ConnectorComparison.Operator.EQ,
+                            ConnectorLiteral.ofLong(1))).kind());
+        }
+        var schema = schema("BIGINT");
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                comparison(schema, ConnectorComparison.Operator.EQ, 
ConnectorLiteral.ofLong(1))).kind());
+    }
+
+    @Test
+    void literalDotDollarAndNestedPathsStayLocal() {
+        for (List<String> path : List.of(List.of("a.b"), List.of("$x"), 
List.of("a", "b"))) {
+            var schema = schema("v", path, "BIGINT", List.of("long"));
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                    comparison(schema, ConnectorComparison.Operator.EQ, 
ConnectorLiteral.ofLong(1))).kind());
+        }
+    }
+
+    @Test
+    void likeUsesOnlyAnEscapedNecessaryLiteralAndKeepsResidualClassification() 
{
+        var schema = schema("STRING", "string");
+        for (Map.Entry<String, String> example : Map.of("%a.b%", "a\\.b", 
"x_y%abc", "abc",
+                "%中文%", "中文", "%a\\%%", "a%", "%[x]%", "\\[x\\]").entrySet()) {
+            var predicate = new ConnectorLike(ConnectorLike.Operator.LIKE, 
column(schema),
+                    ConnectorLiteral.ofString(example.getKey()));
+            var result = translate(schema, predicate);
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET, 
result.kind());
+            Assertions.assertEquals(example.getValue(), 
result.filter().get("Source", Document.class).get("$regex"));
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                    new MongoPredicateTranslator(schema, 
false).translate(predicate).kind());
+        }
+    }
+
+    @Test
+    void regexWildcardOnlyDanglingEscapeAndNulAreNotTranslated() {
+        var schema = schema("STRING", "string");
+        for (String pattern : List.of("%_", "", "abc\\", "a\u0000b", "\\q")) {
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                    new ConnectorLike(ConnectorLike.Operator.LIKE, 
column(schema), ConnectorLiteral.ofString(pattern))).kind());
+        }
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                new ConnectorLike(ConnectorLike.Operator.REGEXP, 
column(schema), ConnectorLiteral.ofString("a"))).kind());
+    }
+
+    @Test
+    void predicateBudgetsBoundInListsAndRecursiveTrees() {
+        var schema = schema("INT", "int");
+        List<ConnectorExpression> list = new ArrayList<>();
+        for (int i = 0; i < 1025; i++) {
+            list.add(ConnectorLiteral.ofLong(i));
+        }
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED,
+                translate(schema, new ConnectorIn(column(schema), list, 
false)).kind());
+        ConnectorExpression expression = comparison(schema, 
ConnectorComparison.Operator.EQ, ConnectorLiteral.ofLong(1));
+        for (int i = 0; i < 65; i++) {
+            expression = new ConnectorAnd(List.of(expression));
+        }
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema, expression).kind());
+    }
+
+    @Test
+    void oversizedTextLiteralDoesNotAllocateAnUnboundedBsonCommand() {
+        var schema = schema("STRING", "string");
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema,
+                comparison(schema, ConnectorComparison.Operator.EQ,
+                        ConnectorLiteral.ofString("x".repeat(65537)))).kind());
+    }
+
+    @Test
+    void expressionSpiDatetimeScaleMatchesTheSchemaDatetimePrecision() {
+        var schema = schema("DATETIME(3)", "date");
+        var ref = new ConnectorColumnRef("v", ConnectorType.of("DATETIMEV2", 
-1, 3));
+        var filter = new ConnectorComparison(ConnectorComparison.Operator.GE, 
ref,
+                ConnectorLiteral.ofDatetime(LocalDateTime.of(2024, 1, 1, 0, 
0)));
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET, 
translate(schema, filter).kind());
+    }
+
+    @Test
+    void expressionSpiDecimalStorageNameMatchesTheSchemaDecimalFamily() {
+        var schema = schema("DECIMAL(20,2)", "decimal");
+        var ref = new ConnectorColumnRef("v", ConnectorType.of("DECIMAL128", 
20, 2));
+        var filter = new ConnectorComparison(ConnectorComparison.Operator.EQ, 
ref,
+                ConnectorLiteral.ofDecimal(new BigDecimal("1.20"), 20, 2));
+        Assertions.assertEquals(MongoPredicateTranslator.Kind.SUPERSET, 
translate(schema, filter).kind());
+    }
+
+    @Test
+    void arrayAndJsonIsNotNullCannotUseMongoArrayElementNullSemantics() {
+        for (String type : List.of("ARRAY<STRING>", "JSON")) {
+            var schema = schema(type, "array");
+            var predicate = new ConnectorIsNull(column(schema), true);
+            Assertions.assertEquals(MongoPredicateTranslator.Kind.UNSUPPORTED, 
translate(schema, predicate).kind());
+        }
+    }
+
+}
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoScanPlanTest.java
 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoScanPlanTest.java
index 1c07f6c78b4..6ed084ed152 100644
--- 
a/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoScanPlanTest.java
+++ 
b/fe/fe-connector/fe-connector-mongodb/src/test/java/org/apache/doris/connector/mongodb/MongoScanPlanTest.java
@@ -18,6 +18,10 @@
 package org.apache.doris.connector.mongodb;
 
 import org.apache.doris.connector.spi.ConnectorSession;
+import org.apache.doris.connector.spi.ConnectorType;
+import org.apache.doris.connector.spi.pushdown.ConnectorColumnRef;
+import org.apache.doris.connector.spi.pushdown.ConnectorComparison;
+import org.apache.doris.connector.spi.pushdown.ConnectorLiteral;
 import org.apache.doris.connector.spi.scan.ConnectorScanRange;
 import org.apache.doris.connector.spi.scan.ConnectorScanRequest;
 import org.apache.doris.connector.spi.scan.ScanNodePropertiesResult;
@@ -26,6 +30,7 @@ import org.apache.doris.thrift.TMongoScanDesc;
 import org.apache.doris.thrift.TTableFormatFileDesc;
 
 import org.bson.Document;
+import org.bson.RawBsonDocument;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
@@ -34,7 +39,7 @@ import java.util.Map;
 import java.util.Optional;
 
 class MongoScanPlanTest {
-    private static final class Session implements ConnectorSession {
+    private static class Session implements ConnectorSession {
         private final Map<String, String> policies;
 
         Session() {
@@ -233,4 +238,119 @@ class MongoScanPlanTest {
                 .planScan(new Session(), ConnectorScanRequest.builder(handle, 
List.of(stale)).build()));
     }
 
+    @Test
+    void nullPolicyEnablesCandidatesWithoutConsumingResiduals() {
+        MongoCatalogProperties properties = MongoCatalogProperties.of(Map.of(
+                "mongodb.uri", "mongodb://localhost:27017", 
"mongodb.type_mismatch", "null",
+                "mongodb.schema", 
"{\"sample.records\":{\"columns\":[{\"name\":\"seq\","
+                        + 
"\"path\":[\"seq\"],\"doris_type\":\"BIGINT\",\"bson_types\":[\"long\"]}]}}"));
+        MongoTableHandle handle = new MongoTableHandle("sample",
+                new Document("name", "records").append("type", "collection"), 
properties);
+        var expression = new 
ConnectorComparison(ConnectorComparison.Operator.GE,
+                new ConnectorColumnRef("seq", ConnectorType.of("BIGINT")), 
ConnectorLiteral.ofLong(10));
+        var result = new 
MongoScanPlanProvider(properties).getScanNodePropertiesResult(new Session(), 
handle,
+                List.of(new 
MongoColumnHandle(handle.getSchema().getBindings().get(0),
+                        handle.getSchema().getVersion())), 
Optional.of(expression));
+        Assertions.assertEquals("SUPERSET", 
result.getProperties().get("predicate_pushdown"));
+        Assertions.assertFalse(result.hasConjunctTracking());
+    }
+
+    private MongoCatalogProperties typedProperties(String policy, List<String> 
path) {
+        Document column = new Document("name", "seq").append("path", path)
+                .append("doris_type", "BIGINT").append("bson_types", 
List.of("long"));
+        return MongoCatalogProperties.of(Map.of("mongodb.uri", 
"mongodb://localhost:27017",
+                "mongodb.type_mismatch", policy, "mongodb.schema",
+                new Document("sample.records", new Document("columns", 
List.of(column))).toJson()));
+    }
+
+    private TMongoScanDesc descriptor(MongoCatalogProperties properties, 
String kind, ConnectorSession session,
+            boolean columns) {
+        MongoTableHandle table = new MongoTableHandle("sample",
+                new Document("name", "records").append("type", kind), 
properties);
+        var binding = table.getSchema().getBindings().get(0);
+        var filter = new ConnectorComparison(ConnectorComparison.Operator.GE,
+                new ConnectorColumnRef("seq", binding.column().getType()), 
ConnectorLiteral.ofLong(10));
+        var request = ConnectorScanRequest.builder(table,
+                columns ? List.of(new MongoColumnHandle(binding, 
table.getSchema().getVersion())) : List.of())
+                .filter(Optional.of(filter)).build();
+        var range = new MongoScanPlanProvider(properties).planScan(session, 
request).get(0);
+        var result = new TTableFormatFileDesc();
+        range.populateRangeParams(result, new TFileRangeDesc());
+        return result.getMongodbParams();
+    }
+
+    @Test
+    void scanRangeCarriesBsonRatherThanRelaxedJsonOrUntypedNumbers() {
+        var descriptor = descriptor(typedProperties("null", 
List.of("Source")), "collection", new Session(), true);
+        var filter = new RawBsonDocument(descriptor.getFilterBson());
+        Assertions.assertEquals(10, 
filter.getDocument("Source").getInt64("$gte").getValue());
+        var projection = new RawBsonDocument(descriptor.getProjectionBson());
+        Assertions.assertEquals(1, projection.getInt32("Source").getValue());
+        Assertions.assertEquals(0, projection.getInt32("_id").getValue());
+    }
+
+    @Test
+    void strictAndViewScansCannotHideHistoricalTypeFailures() {
+        Assertions.assertFalse(descriptor(typedProperties("error", 
List.of("seq")),
+                "collection", new Session(), true).isSetFilterBson());
+        Assertions.assertFalse(descriptor(typedProperties("null", 
List.of("seq")),
+                "view", new Session(), true).isSetFilterBson());
+    }
+
+    @Test
+    void statementSwitchesDisableRemoteWorkIndependently() {
+        var session = new Session() {
+            @Override
+            public Map<String, String> getSessionProperties() {
+                return Map.of("enable_mongodb_predicate_pushdown", "false",
+                        "enable_mongodb_projection_pushdown", "false");
+            }
+        };
+        var descriptor = descriptor(typedProperties("null", List.of("seq")), 
"collection", session, true);
+        Assertions.assertFalse(descriptor.isSetFilterBson());
+        Assertions.assertFalse(descriptor.isSetProjectionBson());
+    }
+
+    @Test
+    void projectionKeepsWholeRootsForPathErrorsAndPrunedStructChildren() {
+        var descriptor = descriptor(typedProperties("error", List.of("Parent", 
"Child")),
+                "collection", new Session(), true);
+        var projection = new RawBsonDocument(descriptor.getProjectionBson());
+        Assertions.assertEquals(1, projection.getInt32("Parent").getValue());
+        Assertions.assertFalse(projection.containsKey("Parent.Child"));
+        Assertions.assertFalse(descriptor.isSetFilterBson());
+    }
+
+    @Test
+    void literalDotAndWholeDocumentBindingsDisableProjection() {
+        Assertions.assertFalse(descriptor(typedProperties("null", 
List.of("literal.dot")),
+                "collection", new Session(), true).isSetProjectionBson());
+        var table = new MongoTableHandle("sample", new Document("name", 
"records").append("type", "collection"),
+                properties());
+        var request = ConnectorScanRequest.builder(table, List.of(new 
MongoColumnHandle(
+                table.getSchema().getBindings().get(0), 
table.getSchema().getVersion()))).build();
+        var result = new TTableFormatFileDesc();
+        new MongoScanPlanProvider(properties()).planScan(new Session(), 
request).get(0)
+                .populateRangeParams(result, new TFileRangeDesc());
+        
Assertions.assertFalse(result.getMongodbParams().isSetProjectionBson());
+    }
+
+    @Test
+    void countOnlyProjectionPreservesOneDocumentPerSourceRow() {
+        var d = descriptor(typedProperties("null", List.of("seq")), 
"collection", new Session(), false);
+        Assertions.assertEquals(1, new 
RawBsonDocument(d.getProjectionBson()).getInt32("_id").getValue());
+    }
+
+    @Test
+    void strictSqlCastErrorsAlsoKeepCandidatesLocal() {
+        var session = new Session() {
+            @Override
+            public Map<String, String> getSessionProperties() {
+                return Map.of("enable_strict_cast", "true");
+            }
+        };
+        Assertions.assertFalse(descriptor(typedProperties("null", 
List.of("seq")),
+                "collection", session, true).isSetFilterBson());
+    }
+
 }
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 7544a5948da..46b48196b4a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -3108,6 +3108,21 @@ public class SessionVariable implements Serializable, 
Writable {
                     + "inherit follows the catalog policy; shared snapshots 
are not supported")
     public String mongodbReadConcern = "inherit";
 
+    @VarAttrDef.VarAttr(name = "enable_mongodb_predicate_pushdown", 
needForward = true,
+            affectQueryResultInExecution = true,
+            description = "Enable verified MongoDB candidate predicates; 
strict errors and views remain local")
+    public boolean enableMongoDBPredicatePushdown = true;
+
+    @VarAttrDef.VarAttr(name = "enable_mongodb_like_pushdown", needForward = 
true,
+            affectQueryResultInExecution = true,
+            description = "Enable conservative MongoDB LIKE candidates with 
local residual evaluation")
+    public boolean enableMongoDBLikePushdown = true;
+
+    @VarAttrDef.VarAttr(name = "enable_mongodb_projection_pushdown", 
needForward = true,
+            affectQueryResultInExecution = true,
+            description = "Read only MongoDB roots required by projections and 
residual predicates")
+    public boolean enableMongoDBProjectionPushdown = true;
+
     public static final String FLUSS_UNION_READ_MODE = "fluss_union_read_mode";
 
     @VarAttrDef.VarAttr(name = FLUSS_UNION_READ_MODE,
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/connector/ConnectorSessionImplTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/connector/ConnectorSessionImplTest.java
index 0df3af0bacf..b15e45c3808 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/connector/ConnectorSessionImplTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/connector/ConnectorSessionImplTest.java
@@ -438,4 +438,32 @@ public class ConnectorSessionImplTest {
         public void close() {
         }
     }
+
+    @Test
+    public void 
testMongoDBPushdownSwitchesReachConnectorsAndForwardedStatements() {
+        ConnectContext ctx = new ConnectContext();
+        ctx.setThreadLocalInfo();
+        try {
+            var initial = 
ConnectorSessionBuilder.from(ctx).build().getSessionProperties();
+            for (String key : 
java.util.List.of("enable_mongodb_predicate_pushdown",
+                    "enable_mongodb_like_pushdown", 
"enable_mongodb_projection_pushdown")) {
+                Assertions.assertEquals("true", initial.get(key));
+            }
+            ctx.getSessionVariable().enableMongoDBPredicatePushdown = false;
+            ctx.getSessionVariable().enableMongoDBLikePushdown = false;
+            ctx.getSessionVariable().enableMongoDBProjectionPushdown = false;
+            SessionVariable forwarded = new SessionVariable();
+            
forwarded.setForwardedSessionVariables(ctx.getSessionVariable().getForwardVariables());
+            ctx.setSessionVariable(forwarded);
+            var actual = 
ConnectorSessionBuilder.from(ctx).build().getSessionProperties();
+            for (String key : 
java.util.List.of("enable_mongodb_predicate_pushdown",
+                    "enable_mongodb_like_pushdown", 
"enable_mongodb_projection_pushdown")) {
+                Assertions.assertEquals("false", actual.get(key));
+            }
+            Assertions.assertEquals("true", 
initial.get("enable_mongodb_predicate_pushdown"));
+        } finally {
+            ConnectContext.remove();
+        }
+    }
+
 }
diff --git a/gensrc/thrift/PlanNodes.thrift b/gensrc/thrift/PlanNodes.thrift
index 9a9f99b68d5..716ea7e4cfb 100644
--- a/gensrc/thrift/PlanNodes.thrift
+++ b/gensrc/thrift/PlanNodes.thrift
@@ -717,6 +717,10 @@ struct TMongoScanDesc {
     // Maximum simultaneously leased clients in this pool, keyed by 
catalog/configuration and
     // connection policy. This is not a query-wide or source-wide 
scanner-concurrency budget.
     22: optional i32 pool_max_clients
+    // Typed BSON candidate filter; the Doris residual is retained. Absent 
means scan all documents.
+    23: optional binary filter_bson
+    // BSON inclusion projection of complete source roots. Absent means return 
the complete document.
+    24: optional binary projection_bson
 }
 
 struct TTableFormatFileDesc {
diff --git a/regression-test/data/external_table_p0/mongodb/test_mongodb_m1.out 
b/regression-test/data/external_table_p0/mongodb/test_mongodb_m1.out
new file mode 100644
index 00000000000..b426e4e2d34
--- /dev/null
+++ b/regression-test/data/external_table_p0/mongodb/test_mongodb_m1.out
@@ -0,0 +1,363 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !filter_false_0 --
+1      9007199254740993        alpha
+
+-- !filter_false_1 --
+2      -9007199254740993       a.b
+
+-- !filter_false_2 --
+10     10      
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_false_3 --
+6      20      line\nalpha
+7      7       a%_b
+
+-- !filter_false_4 --
+
+-- !filter_false_5 --
+3      \N      \N
+4      \N      \N
+5      \N      中文-é
+
+-- !filter_false_6 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_false_7 --
+7      7       a%_b
+
+-- !filter_false_8 --
+3      \N      \N
+4      \N      \N
+5      \N      中文-é
+
+-- !filter_false_9 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+6      20      line\nalpha
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_false_10 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_false_11 --
+7      7       a%_b
+
+-- !filter_false_12 --
+
+-- !filter_false_13 --
+1      9007199254740993        alpha
+5      \N      中文-é
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_false_14 --
+1      9007199254740993        alpha
+
+-- !filter_false_15 --
+5      \N      中文-é
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_false_16 --
+2      -9007199254740993       a.b
+
+-- !filter_false_17 --
+5      \N      中文-é
+
+-- !filter_false_18 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_false_19 --
+
+-- !filter_false_20 --
+1      9007199254740993        alpha
+2      -9007199254740993       a.b
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_false_21 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+5      \N      中文-é
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_false_22 --
+10     10      
+
+-- !filter_false_23 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_false_24 --
+1      9007199254740993        alpha
+
+-- !filter_false_25 --
+2      -9007199254740993       a.b
+
+-- !filter_false_26 --
+1      9007199254740993        alpha
+2      -9007199254740993       a.b
+
+-- !filter_false_27 --
+1      9007199254740993        alpha
+
+-- !filter_false_28 --
+10     10      
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !types_false --
+1      9007199254740993        123.45  1969-12-31T23:59:59.999 -1      00FF80  
[{"amount":1.20, "tags":["a", null]}, null, {"amount":null, "tags":null}]
+10     10      \N      \N      \N      \N      \N
+2      -9007199254740993       -2.50   1970-01-01T00:00        0               
[]
+3      \N      \N      \N      \N      \N      \N
+4      \N      \N      \N      \N      \N      \N
+5      \N      \N      \N      253402300800000 \N      \N
+6      20      \N      9999-12-31T23:59:59.999 253402300799999 \N      \N
+7      7       \N      \N      \N      \N      \N
+8      8       \N      \N      \N      \N      \N
+9      9       \N      \N      \N      \N      \N
+
+-- !count_false --
+10
+
+-- !aggregate_false --
+false  3       \N
+true   3       123.45
+
+-- !join_false --
+
+-- !residual_limit_false --
+1
+6
+
+-- !collation_false --
+1      alpha
+
+-- !view_false --
+3      view-中文-é
+
+-- !timeseries_false --
+a      3       2
+
+-- !array_not_null_false --
+1      ["red", "blue"]
+2      []
+3      [null, "中文"]
+
+-- !json_not_null_false --
+1      ["red","blue"]
+2      []
+3      [null,"中文"]
+
+-- !paths_false --
+1      10      a.b
+2      \N      value
+
+-- !filter_true_0 --
+1      9007199254740993        alpha
+
+-- !filter_true_1 --
+2      -9007199254740993       a.b
+
+-- !filter_true_2 --
+10     10      
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_true_3 --
+6      20      line\nalpha
+7      7       a%_b
+
+-- !filter_true_4 --
+
+-- !filter_true_5 --
+3      \N      \N
+4      \N      \N
+5      \N      中文-é
+
+-- !filter_true_6 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_true_7 --
+7      7       a%_b
+
+-- !filter_true_8 --
+3      \N      \N
+4      \N      \N
+5      \N      中文-é
+
+-- !filter_true_9 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+6      20      line\nalpha
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_true_10 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_true_11 --
+7      7       a%_b
+
+-- !filter_true_12 --
+
+-- !filter_true_13 --
+1      9007199254740993        alpha
+5      \N      中文-é
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_true_14 --
+1      9007199254740993        alpha
+
+-- !filter_true_15 --
+5      \N      中文-é
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_true_16 --
+2      -9007199254740993       a.b
+
+-- !filter_true_17 --
+5      \N      中文-é
+
+-- !filter_true_18 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_true_19 --
+
+-- !filter_true_20 --
+1      9007199254740993        alpha
+2      -9007199254740993       a.b
+7      7       a%_b
+8      8       alpha 
+
+-- !filter_true_21 --
+1      9007199254740993        alpha
+10     10      
+2      -9007199254740993       a.b
+5      \N      中文-é
+6      20      line\nalpha
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !filter_true_22 --
+10     10      
+
+-- !filter_true_23 --
+1      9007199254740993        alpha
+6      20      line\nalpha
+8      8       alpha 
+
+-- !filter_true_24 --
+1      9007199254740993        alpha
+
+-- !filter_true_25 --
+2      -9007199254740993       a.b
+
+-- !filter_true_26 --
+1      9007199254740993        alpha
+2      -9007199254740993       a.b
+
+-- !filter_true_27 --
+1      9007199254740993        alpha
+
+-- !filter_true_28 --
+10     10      
+7      7       a%_b
+8      8       alpha 
+9      9       ALPHA
+
+-- !types_true --
+1      9007199254740993        123.45  1969-12-31T23:59:59.999 -1      00FF80  
[{"amount":1.20, "tags":["a", null]}, null, {"amount":null, "tags":null}]
+10     10      \N      \N      \N      \N      \N
+2      -9007199254740993       -2.50   1970-01-01T00:00        0               
[]
+3      \N      \N      \N      \N      \N      \N
+4      \N      \N      \N      \N      \N      \N
+5      \N      \N      \N      253402300800000 \N      \N
+6      20      \N      9999-12-31T23:59:59.999 253402300799999 \N      \N
+7      7       \N      \N      \N      \N      \N
+8      8       \N      \N      \N      \N      \N
+9      9       \N      \N      \N      \N      \N
+
+-- !count_true --
+10
+
+-- !aggregate_true --
+false  3       \N
+true   3       123.45
+
+-- !join_true --
+
+-- !residual_limit_true --
+1
+6
+
+-- !collation_true --
+1      alpha
+
+-- !view_true --
+3      view-中文-é
+
+-- !timeseries_true --
+a      3       2
+
+-- !array_not_null_true --
+1      ["red", "blue"]
+2      []
+3      [null, "中文"]
+
+-- !json_not_null_true --
+1      ["red","blue"]
+2      []
+3      [null,"中文"]
+
+-- !paths_true --
+1      10      a.b
+2      \N      value
+
+-- !remote_read_counts --
+10     1
+
+-- !statement_switch_restored --
+true   true
+
diff --git 
a/regression-test/suites/external_table_p0/mongodb/test_mongodb_m1.groovy 
b/regression-test/suites/external_table_p0/mongodb/test_mongodb_m1.groovy
new file mode 100644
index 00000000000..d1909f7ff37
--- /dev/null
+++ b/regression-test/suites/external_table_p0/mongodb/test_mongodb_m1.groovy
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.action.ProfileAction
+
+import groovy.json.JsonOutput
+
+suite("test_mongodb_m1", "p0,external") {
+    if 
(!"true".equalsIgnoreCase(context.config.otherConfigs.get("enableMongoDBTest")))
 {
+        return
+    }
+    String host = context.config.otherConfigs.get("externalEnvIp")
+    String port = context.config.otherConfigs.get("mongodb_port")
+    def quote = { value -> "'${value.toString().replace("\\", 
"\\\\").replace("'", "\\'")}'" }
+    def col = { String name, String type, List tags, List path = null ->
+        [name: name, path: path ?: [name], doris_type: type, bson_types: tags]
+    }
+    List fields = [col("seq", "BIGINT", ["long"]), col("n", "BIGINT", ["int", 
"long"]),
+        col("text", "STRING", ["string"]), col("active", "BOOLEAN", ["bool"]),
+        col("amount", "DECIMAL(20,2)", ["decimal"]), col("observed", 
"DATETIME(3)", ["date"]),
+        col("epoch_ms", "BIGINT", ["date"], ["observed"]),
+        col("bytes", "VARBINARY", ["binData"]),
+        col("nested", 
"ARRAY<STRUCT<amount:DECIMAL(10,2),tags:ARRAY<STRING>>>", ["array"])]
+    fields.find { it.name == "bytes" }.subtype = 0
+    Map manifest = ["doris_mongodb_m1.records": [columns: fields],
+        "doris_mongodb_m1.dirty": [columns: fields.take(2)],
+        "doris_mongodb_m1.collated": [columns: [fields[0], fields[2]]],
+        "doris_mongodb_m1.paths": [columns: [fields[0], col("child", "BIGINT", 
["long"], ["a", "b"]),
+            col("literal", "STRING", ["string"], ["literal.dot"])]],
+        "doris_mongodb_native.typed_records": [columns: [fields[0], 
col("tags", "ARRAY<STRING>", ["array"]),
+            col("json_tags", "JSON", ["array"], ["tags"])]],
+        "doris_mongodb_native.record_view": [columns: [fields[0], col("label", 
"STRING", ["string"])]],
+        "doris_mongodb_native.measurements": [columns: [fields[5], 
col("device", "STRING", ["string"]),
+            col("value", "INT", ["int"])]]]
+    for (String policy : ["error", "null"]) {
+        sql "DROP CATALOG IF EXISTS mongodb_m1_${policy}"
+        Map properties = ["type": "mongodb", "mongodb.uri": 
"mongodb://${host}:${port}",
+            "mongodb.username": 
context.config.otherConfigs.get("mongodb_user"),
+            "mongodb.password": 
context.config.otherConfigs.get("mongodb_password"),
+            "mongodb.databases": "doris_mongodb_m1,doris_mongodb_native", 
"mongodb.type_mismatch": policy,
+            "mongodb.schema": JsonOutput.toJson(manifest)]
+        sql "CREATE CATALOG mongodb_m1_${policy} PROPERTIES 
(${properties.collect { k, v -> "${quote(k)}=${quote(v)}" }.join(',')})"
+    }
+    List predicates = ["n = 9007199254740993", "n < -9007199254740992", "n >= 
7 AND n <= 20",
+        "n IN (7, 20, NULL)", "n NOT IN (7, NULL)", "n IS NULL", "n IS NOT 
NULL", "n <=> 7", "n <=> NULL",
+        "n != 7", "n = 7 OR text LIKE '%alpha%'", "n = 7 OR cast(text AS 
BIGINT) = 20",
+        "cast(text AS BIGINT) = 20", "active = true", "text = 'alpha'", "text 
> 'alpha'",
+        "text LIKE '%a.b%'", "text LIKE '%中文%'", "text LIKE '%alpha%'", "text 
LIKE 'a_c%'",
+        "text LIKE 'a%'", "text LIKE '%'", "text LIKE ''", "text REGEXP 'pha'",
+        "amount = 123.45", "amount >= -2.50 AND amount <= 1.23",
+        "observed >= '1969-12-31 23:59:59.999' AND observed < '1970-01-01 
00:00:00.001'",
+        "epoch_ms = -1", "n BETWEEN 7 AND 10"]
+    for (boolean enabled : [false, true]) {
+        sql "SET enable_mongodb_predicate_pushdown=${enabled}"
+        sql "SET enable_mongodb_projection_pushdown=${enabled}"
+        sql "SET enable_mongodb_like_pushdown=${enabled}"
+        sql "SWITCH mongodb_m1_null"
+        sql "USE doris_mongodb_m1"
+        for (int i = 0; i < predicates.size(); i++) {
+            "order_qt_filter_${enabled}_${i}" "SELECT seq, n, text FROM 
records WHERE ${predicates[i]}"
+        }
+        "order_qt_types_${enabled}" """SELECT seq, n, amount, observed, 
epoch_ms,
+            from_binary(bytes), cast(nested AS STRING) FROM records"""
+        "order_qt_count_${enabled}" "SELECT count(*) FROM records"
+        "order_qt_aggregate_${enabled}" "SELECT active, count(*), sum(amount) 
FROM records WHERE n >= 7 GROUP BY active"
+        "order_qt_join_${enabled}" "SELECT a.seq, b.seq FROM records a JOIN 
records b ON a.n = b.n WHERE a.seq < b.seq"
+        "order_qt_residual_limit_${enabled}" "SELECT seq FROM records WHERE n 
>= 7 AND length(text) > 2 ORDER BY seq LIMIT 2"
+        "order_qt_collation_${enabled}" "SELECT seq, text FROM collated WHERE 
text = 'alpha'"
+        "order_qt_view_${enabled}" """SELECT seq, label FROM 
mongodb_m1_null.doris_mongodb_native.record_view
+            WHERE label = 'VIEW-ALPHA' OR label LIKE '%中文%'"""
+        "order_qt_timeseries_${enabled}" """SELECT device, sum(value), count(*)
+            FROM mongodb_m1_null.doris_mongodb_native.measurements
+            WHERE observed >= '2024-01-01 00:00:00.001' AND observed < 
'2024-01-02 00:00:00' GROUP BY device"""
+        "order_qt_array_not_null_${enabled}" """SELECT seq, tags
+            FROM mongodb_m1_null.doris_mongodb_native.typed_records WHERE tags 
IS NOT NULL"""
+        "order_qt_json_not_null_${enabled}" """SELECT seq, cast(json_tags AS 
STRING)
+            FROM mongodb_m1_null.doris_mongodb_native.typed_records WHERE 
json_tags IS NOT NULL"""
+        "order_qt_paths_${enabled}" "SELECT seq, child, literal FROM paths"
+        test {
+            sql "SELECT seq, n FROM mongodb_m1_error.doris_mongodb_m1.dirty 
WHERE seq = 1"
+            exception "BSON"
+        }
+        test {
+            sql "SELECT seq, child FROM 
mongodb_m1_error.doris_mongodb_m1.paths"
+            exception "BSON"
+        }
+    }
+    sql "SET enable_mongodb_predicate_pushdown=true"
+    sql "SET enable_mongodb_projection_pushdown=true"
+    sql "SET enable_mongodb_like_pushdown=true"
+    explain {
+        sql "SELECT seq FROM records WHERE n >= 7"
+        contains "MongoDB predicate: SUPERSET"
+        contains "residual: retained"
+    }
+    explain {
+        sql "SELECT seq FROM mongodb_m1_error.doris_mongodb_m1.dirty WHERE seq 
= 1"
+        contains "MongoDB predicate: UNSUPPORTED"
+    }
+    explain {
+        sql "SELECT /*+ SET_VAR(enable_mongodb_predicate_pushdown=false) */ 
seq FROM records WHERE n >= 7"
+        contains "MongoDB predicate: UNSUPPORTED"
+    }
+    explain {
+        sql "SELECT /*+ SET_VAR(enable_mongodb_like_pushdown=false) */ seq 
FROM records WHERE text LIKE '%alpha%'"
+        contains "MongoDB predicate: UNSUPPORTED"
+    }
+    explain {
+        sql "SELECT /*+ SET_VAR(enable_strict_cast=true) */ seq FROM records 
WHERE n >= 7"
+        contains "MongoDB predicate: UNSUPPORTED"
+    }
+    explain {
+        sql """SELECT value FROM 
mongodb_m1_null.doris_mongodb_native.measurements
+            WHERE observed >= '2024-01-01 00:00:00.001' AND observed < 
'2024-01-02 00:00:00'"""
+        contains "MongoDB predicate: SUPERSET"
+    }
+    explain {
+        sql "SELECT seq FROM records WHERE amount = 123.45"
+        contains "MongoDB predicate: SUPERSET"
+    }
+    def profileAction = new ProfileAction(context)
+    def sourceRows = { boolean pushdown ->
+        String token = "mongodb_m1_" + UUID.randomUUID().toString()
+        sql """SELECT /*+ SET_VAR(enable_profile=true,profile_level=2,
+            enable_mongodb_predicate_pushdown=${pushdown}) */ '${token}', seq
+            FROM records WHERE n = 9007199254740993"""
+        String profile = profileAction.getProfileBySql(token, 
["MongoRowsRead"])
+        def counter = profile =~ /MongoRowsRead:\s*([0-9]+)/
+        if (!counter.find()) {
+            throw new IllegalStateException("MongoDB source row counter is 
absent from the completed profile")
+        }
+        return Long.parseLong(counter.group(1))
+    }
+    long withoutCandidate = sourceRows(false)
+    long withCandidate = sourceRows(true)
+    qt_remote_read_counts "SELECT ${withoutCandidate}, ${withCandidate}"
+    order_qt_statement_switch_restored "SELECT 
@@enable_mongodb_predicate_pushdown, @@enable_mongodb_like_pushdown"
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to