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 4f40ac9067d [chore](build) Add native MongoDB client dependencies 
(#70249)
4f40ac9067d is described below

commit 4f40ac9067d9f9de98e7ebbd1a6052527ece5c2b
Author: Gabriel <[email protected]>
AuthorDate: Fri Nov 6 10:14:53 2026 +0800

    [chore](build) Add native MongoDB client dependencies (#70249)
    
    ### Background
    
    Doris loads FE connectors in isolated plugin directories, while BE
    native clients are built through the shared third-party toolchain. A
    native MongoDB connector needs the synchronous Java client for FE
    metadata access and the C driver/BSON libraries for BE reads.
    
    ### What problem does this PR solve?
    
    Issue Number: None
    Related PR: None
    PR Type: Release/Dependency
    
    Problem Summary:
    
    Prepare the client dependencies and build outputs needed for native
    MongoDB catalog development. Build libmongoc and libbson together,
    expose explicit BE CMake targets, and package an isolated FE dependency
    bundle with aligned MongoDB jars and optional compression providers. The
    bundle is staged as an archive until a connector provider is
    implemented; no catalog or scanner is registered by this change.
    
    ### Details
    
    - **Change map:** 256 added lines of build configuration/dependency
    declarations, 189 lines of license metadata/notices, and 28 lines of
    README. No runtime query code, tests, or generated sources are changed.
    - **Versions:** MongoDB C Driver/libbson 2.5.8; Java
    sync/core/BSON/record codec 5.14.0; snappy-java 1.1.10.10 pinned in the
    MongoDB module; zstd-jni 1.5.7-25.
    - **Upstream changes:** Pin the official [C driver
    release](https://github.com/mongodb/mongo-c-driver/releases/tag/2.5.8)
    and [Java driver
    release](https://github.com/mongodb/mongo-java-driver/releases/tag/r5.14.0).
    C Driver 2.5.8 includes cursor-response, compressed-reply and GridFS
    security fixes; snappy-java 1.1.10.10 includes allocation,
    buffer-boundary and stream-handling fixes. Java compression providers
    are optional SDK dependencies and are included explicitly so configured
    compressor URI options work for FE metadata access as well as BE reads.
    - **Compatibility:** Use Doris-managed OpenSSL, Cyrus SASL, Snappy, zstd
    and zlib; enable SRV and bundled utf8proc. Native archives are
    PIC/static. Checked initial-cache paths and restricted pkg-config lookup
    prevent host dependencies from being selected. The Java BOM is
    module-local, logging remains host-provided, and the BE targets stay
    outside `COMMON_THIRDPARTY` until consumed by a reader.
    - **Rollback:** Revert the dependency registration and bundle staging;
    this change introduces no persisted catalog state.
    
    ### Testing
    
    Locally on Linux x86_64:
    
    - `bash thirdparty/build-thirdparty.sh -j 8 mongo_c_driver`: builds and
    installs both static libraries successfully.
    - A standalone CMake/C++ consumer links the actual BE `mongoc2`/`bson2`
    targets and runs BSON/ObjectId, client lifecycle and
    snapshot-session-options smoke checks. Required TLS/SASL/SRV/compression
    feature macros are enabled.
    - An empty managed dependency prefix fails configuration instead of
    selecting host OpenSSL.
    - `mvn -f fe/pom.xml -pl :fe-connector-mongodb -am package -DskipTests
    -Dskip.doc=true -Dmaven.build.cache.enabled=false`: succeeds, including
    FE Checkstyle and the connector import gate. No module unit tests are
    claimed.
    - Inspect the produced archive: exactly the six intended runtime jars,
    aligned MongoDB versions, and no logging binding. Run Java raw
    BSON/read-options smoke checks and Snappy/Zstd JNI compression round
    trips against those jars.
    - Execute the added `build.sh` staging block and verify the copied
    archive hash and absence of an auto-loaded MongoDB plugin directory.
    - A local negative-input smoke check reproduces `OutOfMemoryError` with
    snappy-java 1.1.10.5 using a five-byte input declaring an oversized
    uncompressed length; the same check against the packaged 1.1.10.10 jar
    rejects the input without that allocation. The JVM is capped at 64 MiB
    for both checks.
    - Verify the C source archive against the official release asset
    SHA-256, its configured MD5, and the unchanged upstream third-party
    notices.
    - Shell syntax and `git diff --check` pass.
    
    The full `build.sh --fe` build was not completed: the existing
    third-party installation lacks `libpaimon_c.a` and
    `paimon_rust/paimon.h`, so its preflight starts an unrelated full
    third-party rebuild. That rebuild was stopped; the scoped validations
    above completed. Other platform and full-build coverage remain for CI.
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Behavior changed: No query behavior change; MongoDB client dependency
    artifacts are added to build outputs.
    - Does this need documentation: No user-facing documentation yet; the
    dependency module README explains the preparation stage.
    - Pre-submission status: Partially verified: dependency builds,
    packaging and smoke checks pass; full FE build and other platforms
    remain for CI.
    
    ### AI Disclosure
    
    - Tool: OpenAI Codex.
    - Generated: Build configuration, dependency module, README, and this
    description. License notices are copied from upstream.
    - Human review: Pending maintainer review; agent self-review completed.
---
 be/cmake/thirdparty.cmake                          |  21 +++
 build.sh                                           |   6 +
 dist/LICENSE-dist.txt                              |   5 +
 dist/licenses/LICENSE-mongo-c-driver.txt           | 184 +++++++++++++++++++++
 fe/fe-connector/fe-connector-mongodb/README.md     |  28 ++++
 fe/fe-connector/fe-connector-mongodb/pom.xml       |  92 +++++++++++
 .../src/main/assembly/plugin-zip.xml               |  48 ++++++
 fe/fe-connector/pom.xml                            |   1 +
 thirdparty/build-thirdparty.sh                     |  36 ++++
 thirdparty/cmake/mongo-c-driver-cache.cmake        |  44 +++++
 thirdparty/vars.sh                                 |   8 +
 11 files changed, 473 insertions(+)

diff --git a/be/cmake/thirdparty.cmake b/be/cmake/thirdparty.cmake
index 6fddbea795b..fb09947e262 100644
--- a/be/cmake/thirdparty.cmake
+++ b/be/cmake/thirdparty.cmake
@@ -201,3 +201,24 @@ add_thirdparty(icudata LIB64)
 
 
 add_thirdparty(pugixml LIB64)
+
+# Prepare explicit targets without enabling a reader or requiring new prebuilt 
libraries yet.
+# For example, existing BE targets keep working until a MongoDB reader links 
mongoc2/bson2.
+add_thirdparty(bson2 LIB64 NOTADD)
+set_target_properties(bson2 PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/include/bson-2.0"
+    INTERFACE_COMPILE_DEFINITIONS BSON_STATIC)
+add_thirdparty(mongoc2 LIB64 NOTADD)
+set_target_properties(mongoc2 PROPERTIES
+    INTERFACE_INCLUDE_DIRECTORIES "${THIRDPARTY_DIR}/include/mongoc-2.0"
+    INTERFACE_COMPILE_DEFINITIONS MONGOC_STATIC)
+# Threads and the platform DNS resolver are OS/toolchain components, not 
vendored libraries.
+find_package(Threads REQUIRED)
+target_link_libraries(mongoc2 INTERFACE
+    bson2 snappy zstd libz cyrus-sasl gssapi_krb5 krb5 k5crypto com_err 
krb5support
+    openssl crypto Threads::Threads ${CMAKE_DL_LIBS})
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+    target_link_libraries(mongoc2 INTERFACE m resolv)
+elseif(OS_MACOSX)
+    target_link_libraries(mongoc2 INTERFACE resolv)
+endif()
diff --git a/build.sh b/build.sh
index 5615b1423b5..279a6f0ad2c 100755
--- a/build.sh
+++ b/build.sh
@@ -838,6 +838,8 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
         fi
     done
     unset _conn_mod
+    # Build the dependency bundle before the native connector provider is 
implemented.
+    modules+=("fe-connector/fe-connector-mongodb")
     # Authorization plugin modules (loaded at runtime from 
plugins/authorization/). Keep this list
     # identical to the deploy loop's (search AUTHZ_PLUGIN_DIR), for the same 
reason as the connectors:
     # the deploy step unzips whatever archive is left in the module's target/, 
so a module built here
@@ -1348,6 +1350,10 @@ if [[ "${BUILD_FE}" -eq 1 ]]; then
     # Deploy connector provider plugins as independent plugin directories.
     # Each sub-directory is one connector backend loaded at runtime by 
ConnectorPluginManager.
     CONN_PLUGIN_DIR="${DORIS_OUTPUT}/fe/plugins/connector"
+    # Keep this dependency-only archive out of auto-discovery, which requires 
a provider class.
+    mkdir -p "${CONN_PLUGIN_DIR}"
+    cp -p 
"${DORIS_HOME}/fe/fe-connector/fe-connector-mongodb/target/doris-fe-connector-mongodb.zip"
 \
+        "${CONN_PLUGIN_DIR}/mongodb.zip"
     for conn_module in es jdbc maxcompute trino hms hive paimon hudi iceberg 
adbc fluss; do
         conn_plugin_target="${CONN_PLUGIN_DIR}/${conn_module}"
         
conn_module_dir="${DORIS_HOME}/fe/fe-connector/fe-connector-${conn_module}"
diff --git a/dist/LICENSE-dist.txt b/dist/LICENSE-dist.txt
index 82e932999bc..153c799845d 100644
--- a/dist/LICENSE-dist.txt
+++ b/dist/LICENSE-dist.txt
@@ -1515,3 +1515,8 @@ Other dependencies:
     * pugixml 1.15 -- licenses/LICENSE-pugixml.txt
     * darts-clone (double-array trie, compiled into the kuromoji dictionary) 
-- licenses/LICENSE-darts-clone.txt
     * mecab-ipadic (IPADIC) 2.7.0-20250920 (Japanese dictionary data shipped 
under be/dict/kuromoji) -- licenses/LICENSE-ipadic.txt
+
+    * MongoDB C Driver (libmongoc/libbson): 2.5.8 -- Apache License 2.0; 
bundled notices in licenses/LICENSE-mongo-c-driver.txt
+    * MongoDB Java Sync Driver (sync/core/bson/bson-record-codec): 5.14.0 -- 
Apache License 2.0
+    * snappy-java (MongoDB bundle): 1.1.10.10 -- Apache License 2.0
+    * zstd-jni (MongoDB bundle): 1.5.7-25 -- licenses/LICENSE-zstd-jni.txt
diff --git a/dist/licenses/LICENSE-mongo-c-driver.txt 
b/dist/licenses/LICENSE-mongo-c-driver.txt
new file mode 100644
index 00000000000..dbab9f4dc0e
--- /dev/null
+++ b/dist/licenses/LICENSE-mongo-c-driver.txt
@@ -0,0 +1,184 @@
+The MongoDB C Driver uses third-party code distributed under different 
licenses.
+
+License notice for uthash
+-------------------------------------------------------------------------------
+
+Copyright (c) 2003-2021, Troy D. Hanson     
http://troydhanson.github.com/uthash/
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License notice for common-b64.c
+-------------------------------------------------------------------------------
+
+ISC License
+
+Copyright: 1996, 1998 Internet Software Consortium
+           1995 International Business Machines, Inc.
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+PERFORMANCE OF THIS SOFTWARE.
+
+Portions Copyright (c) 1995 by International Business Machines, Inc.
+
+International Business Machines, Inc. (hereinafter called IBM) grants
+permission under its copyrights to use, copy, modify, and distribute this
+Software with or without fee, provided that the above copyright notice and
+all paragraphs of this notice appear in all copies, and that the name of IBM
+not be used in connection with the marketing of any product incorporating
+the Software or modifications thereof, without specific, written prior
+permission.
+
+To the extent it has a right to do so, IBM grants an immunity from suit
+under its patents, if any, for the use, sale or manufacture of products to
+the extent that such products are used for performing Domain Name System
+dynamic updates in TCP/IP networks by means of the Software.  No immunity is
+granted for any product per se or for any other function of any product.
+
+THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,
+DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING
+OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN
+IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+License notice for mongoc.css_t
+-------------------------------------------------------------------------------
+
+MIT License
+
+Portions Copyright 2013 by Ignacy Sokolowski.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+License notice for zlib
+-------------------------------------------------------------------------------
+/* zlib.h -- interface of the 'zlib' general purpose compression library
+  version 1.2.11, January 15th, 2017
+
+  Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+  Jean-loup Gailly        Mark Adler
+  [email protected]          [email protected]
+
+
+  The data format used by the zlib library is described by RFCs (Request for
+  Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
+  (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
+*/
+
+License notice for common-md5.c
+-------------------------------------------------------------------------------
+
+ZLib License
+
+Copyright (C) 1999, 2002 Aladdin Enterprises.  All rights reserved.
+
+This software is provided 'as-is', without any express or implied
+warranty.  In no event will the authors be held liable for any damages
+arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose,
+including commercial applications, and to alter it and redistribute it
+freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+3. This notice may not be removed or altered from any source distribution.
+
+L. Peter Deutsch
[email protected]
+
+License notice for utf8proc
+-------------------------------------------------------------------------------
+
+**utf8proc** is a software package originally developed
+by Jan Behrens and the rest of the Public Software Group, who
+deserve nearly all of the credit for this library, that is now maintained by 
the Julia-language developers.  Like the original utf8proc,
+whose copyright and license statements are reproduced below, all new
+work on the utf8proc library is licensed under the [MIT "expat"
+license](http://opensource.org/licenses/MIT):
+
+*Copyright &copy; 2014-2021 by Steven G. Johnson, Jiahao Chen, Tony Kelman, 
Jonas Fonseca, and other contributors listed in the git history.*
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/fe/fe-connector/fe-connector-mongodb/README.md 
b/fe/fe-connector/fe-connector-mongodb/README.md
new file mode 100644
index 00000000000..47d7064cb95
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/README.md
@@ -0,0 +1,28 @@
+# Native MongoDB client dependencies
+
+This module prepares the Java dependencies for the native MongoDB connector. It
+bundles the official synchronous driver, its core, BSON, and BSON record codec
+at one version, using a module-local BOM so other connector plugins keep their
+own dependencies. The archive also carries the Snappy and Zstandard Java 
providers
+so FE metadata reads accept the same compression URI options as the native BE.
+The FE host supplies logging APIs and bindings.
+
+The dependency-only archive does not register a `ConnectorProvider` and cannot
+create a MongoDB catalog. The FE build stages it as
+`plugins/connector/mongodb.zip`, without unpacking it into an auto-loaded 
plugin
+directory. A later connector implementation will add the provider and enable 
the
+normal plugin deployment path.
+
+The BE uses the MongoDB C Driver (`libmongoc` and `libbson`) built together by:
+
+```sh
+bash thirdparty/build-thirdparty.sh mongo_c_driver
+```
+
+The native build produces PIC static archives with OpenSSL, Cyrus SASL, SRV 
DNS,
+Snappy, zstd and zlib support. It reuses Doris-managed dependencies and the 
driver's
+bundled utf8proc for SCRAM-SHA-256. It does not require the C++ driver, a BE 
JVM,
+Reactive Streams, or client-side encryption libraries. The reader and BSON
+`DataTypeSerDe` implementation are separate changes. The BE CMake targets 
`bson2`
+and `mongoc2` expose the static headers, definitions and dependency closure; 
they
+are not added to the common BE link set until a reader consumes them.
diff --git a/fe/fe-connector/fe-connector-mongodb/pom.xml 
b/fe/fe-connector/fe-connector-mongodb/pom.xml
new file mode 100644
index 00000000000..d98638186a1
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/pom.xml
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.doris</groupId>
+        <artifactId>fe-connector</artifactId>
+        <version>${revision}</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>fe-connector-mongodb</artifactId>
+    <packaging>jar</packaging>
+    <name>Doris FE Connector - MongoDB Dependencies</name>
+    <description>Client dependency bundle for the native MongoDB 
connector.</description>
+    <properties>
+        <mongodb.driver.version>5.14.0</mongodb.driver.version>
+        <!-- Override the older FE-wide pin to reject oversized Snappy 
allocations and fix stream handling. -->
+        <mongodb.snappy-java.version>1.1.10.10</mongodb.snappy-java.version>
+        <mongodb.zstd-jni.version>1.5.7-25</mongodb.zstd-jni.version>
+    </properties>
+    <dependencyManagement>
+        <dependencies>
+            <!-- Align the sync driver, core and BSON without changing other 
plugins' closures. -->
+            <dependency>
+                <groupId>org.mongodb</groupId>
+                <artifactId>mongodb-driver-bom</artifactId>
+                <version>${mongodb.driver.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <dependencies>
+        <dependency>
+            <groupId>org.mongodb</groupId>
+            <artifactId>mongodb-driver-sync</artifactId>
+        </dependency>
+        <!-- URI compressors apply to FE metadata reads too; keep both client 
paths usable. -->
+        <dependency>
+            <groupId>org.xerial.snappy</groupId>
+            <artifactId>snappy-java</artifactId>
+            <version>${mongodb.snappy-java.version}</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.github.luben</groupId>
+            <artifactId>zstd-jni</artifactId>
+            <version>${mongodb.zstd-jni.version}</version>
+            <scope>runtime</scope>
+        </dependency>
+    </dependencies>
+    <build>
+        <finalName>doris-fe-connector-mongodb</finalName>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <appendAssemblyId>false</appendAssemblyId>
+                    <descriptors>
+                        
<descriptor>src/main/assembly/plugin-zip.xml</descriptor>
+                    </descriptors>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>make-assembly</id>
+                        <phase>package</phase>
+                        <goals><goal>single</goal></goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git 
a/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml 
b/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml
new file mode 100644
index 00000000000..9fc745f1126
--- /dev/null
+++ b/fe/fe-connector/fe-connector-mongodb/src/main/assembly/plugin-zip.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0";
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 
https://maven.apache.org/xsd/assembly-2.2.0.xsd";>
+    <id>plugin</id>
+    <formats><format>zip</format></formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <files>
+        <file>
+            
<source>${project.build.directory}/${project.build.finalName}.jar</source>
+            <outputDirectory>/</outputDirectory>
+        </file>
+        <file>
+            <source>README.md</source>
+            <outputDirectory>/</outputDirectory>
+        </file>
+    </files>
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>/lib</outputDirectory>
+            <useProjectArtifact>false</useProjectArtifact>
+            <scope>runtime</scope>
+            <!-- The FE host owns logging APIs and bindings; bundling another 
binding splits logging. -->
+            <excludes>
+                <exclude>org.apache.logging.log4j:*</exclude>
+                <exclude>org.slf4j:*</exclude>
+            </excludes>
+        </dependencySet>
+    </dependencySets>
+</assembly>
diff --git a/fe/fe-connector/pom.xml b/fe/fe-connector/pom.xml
index 636bc50720a..f6ff0f9aeda 100644
--- a/fe/fe-connector/pom.xml
+++ b/fe/fe-connector/pom.xml
@@ -69,6 +69,7 @@ under the License.
         <module>fe-connector-metastore-iceberg</module>
         <module>fe-connector-metastore-hms</module>
         <module>fe-connector-es</module>
+        <module>fe-connector-mongodb</module>
         <module>fe-connector-trino</module>
         <module>fe-connector-maxcompute</module>
         <module>fe-connector-jdbc</module>
diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh
index c751afc9491..22f5b9ee737 100755
--- a/thirdparty/build-thirdparty.sh
+++ b/thirdparty/build-thirdparty.sh
@@ -1034,6 +1034,40 @@ build_cyrus_sasl() {
     fi
 }
 
+# MongoDB C Driver: keep libbson and libmongoc at the same release and ABI.
+build_mongo_c_driver() {
+    check_if_source_exist "${MONGO_C_DRIVER_SOURCE}"
+    cd "${TP_SOURCE_DIR}/${MONGO_C_DRIVER_SOURCE}"
+    rm -rf "${BUILD_DIR}"
+    mkdir -p "${BUILD_DIR}"
+    cd "${BUILD_DIR}"
+
+    # Re-root relocatable pkg-config files from prebuilt archives, and exclude 
host packages.
+    PKG_CONFIG_PATH="${TP_LIB_DIR}/pkgconfig" \
+        PKG_CONFIG_LIBDIR="${TP_LIB_DIR}/pkgconfig" \
+        "${CMAKE_CMD}" -G "${GENERATOR}" \
+        -DCMAKE_INSTALL_PREFIX="${TP_INSTALL_DIR}" \
+        -C "${TP_DIR}/cmake/mongo-c-driver-cache.cmake" \
+        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+        -DCMAKE_INSTALL_LIBDIR=lib64 \
+        -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+        -DPKG_CONFIG_ARGN="--define-variable=prefix=${TP_INSTALL_DIR}" \
+        -DENABLE_STATIC=ON -DENABLE_SHARED=OFF -DENABLE_PIC=ON \
+        -DENABLE_TESTS=OFF -DENABLE_EXAMPLES=OFF \
+        -DENABLE_MAN_PAGES=OFF -DENABLE_HTML_DOCS=OFF -DENABLE_UNINSTALL=OFF \
+        -DENABLE_SSL=OPENSSL -DENABLE_SASL=CYRUS -DENABLE_SRV=ON \
+        -DENABLE_SNAPPY=ON -DENABLE_ZSTD=ON -DENABLE_ZLIB=SYSTEM \
+        -DUSE_BUNDLED_UTF8PROC=ON \
+        -DENABLE_CLIENT_SIDE_ENCRYPTION=OFF -DENABLE_MONGODB_AWS_AUTH=OFF \
+        -DENABLE_SHM_COUNTERS=OFF -DENABLE_MAINTAINER_FLAGS=OFF \
+        -DBSON_INSTALL_INCLUDEDIR=include/bson-2.0 \
+        -DMONGOC_INSTALL_INCLUDEDIR=include/mongoc-2.0 ..
+    "${CMAKE_CMD}" --build . --parallel "${PARALLEL}"
+    "${CMAKE_CMD}" --install .
+    strip_lib libbson2.a
+    strip_lib libmongoc2.a
+}
+
 # librdkafka
 build_librdkafka() {
     check_if_source_exist "${LIBRDKAFKA_SOURCE}"
@@ -2695,6 +2729,7 @@ if [[ "${#packages[@]}" -eq 0 ]]; then
         rocksdb
         krb5 # before cyrus_sasl
         cyrus_sasl
+        mongo_c_driver # after OpenSSL, zlib, zstd, Snappy and Cyrus SASL
         librdkafka
         flatbuffers
         orc
@@ -2793,6 +2828,7 @@ cleanup_package_source() {
         brpc)            src_var="BRPC_SOURCE" ;;
         rocksdb)         src_var="ROCKSDB_SOURCE" ;;
         cyrus_sasl)      src_var="CYRUS_SASL_SOURCE" ;;
+        mongo_c_driver)  src_var="MONGO_C_DRIVER_SOURCE" ;;
         librdkafka)      src_var="LIBRDKAFKA_SOURCE" ;;
         flatbuffers)     src_var="FLATBUFFERS_SOURCE" ;;
         arrow)           src_var="ARROW_SOURCE" ;;
diff --git a/thirdparty/cmake/mongo-c-driver-cache.cmake 
b/thirdparty/cmake/mongo-c-driver-cache.cmake
new file mode 100644
index 00000000000..7ee795b7839
--- /dev/null
+++ b/thirdparty/cmake/mongo-c-driver-cache.cmake
@@ -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.
+
+# This initial cache is loaded after -DCMAKE_INSTALL_PREFIX and before 
upstream configuration.
+# Upstream find modules reuse these forced values instead of resolving host 
libraries or stale caches.
+function(doris_mongo_include cache_key header)
+    find_path(DORIS_MONGO_INCLUDE NAMES "${header}"
+              PATHS "${CMAKE_INSTALL_PREFIX}/include"
+              NO_DEFAULT_PATH NO_CACHE REQUIRED)
+    set(${cache_key} "${DORIS_MONGO_INCLUDE}" CACHE PATH "Doris MongoDB 
dependency" FORCE)
+endfunction()
+
+function(doris_mongo_library cache_key archive)
+    find_library(DORIS_MONGO_LIBRARY NAMES "${archive}"
+                 PATHS "${CMAKE_INSTALL_PREFIX}/lib64" 
"${CMAKE_INSTALL_PREFIX}/lib"
+                 NO_DEFAULT_PATH NO_CACHE REQUIRED)
+    set(${cache_key} "${DORIS_MONGO_LIBRARY}" CACHE FILEPATH "Doris MongoDB 
dependency" FORCE)
+endfunction()
+
+doris_mongo_include(OPENSSL_INCLUDE_DIR openssl/ssl.h)
+doris_mongo_library(OPENSSL_SSL_LIBRARY libssl.a)
+doris_mongo_library(OPENSSL_CRYPTO_LIBRARY libcrypto.a)
+doris_mongo_include(SASL2_INCLUDE_DIR sasl/sasl.h)
+doris_mongo_library(SASL2_LIBRARY libsasl2.a)
+doris_mongo_include(SNAPPY_INCLUDE_DIRS snappy-c.h)
+doris_mongo_library(SNAPPY_LIBRARIES libsnappy.a)
+doris_mongo_include(ZLIB_INCLUDE_DIR zlib.h)
+doris_mongo_library(ZLIB_LIBRARY libz.a)
+doris_mongo_include(DORIS_MONGO_ZSTD_INCLUDE_DIR zstd.h)
+doris_mongo_library(pkgcfg_lib_ZSTD_zstd libzstd.a)
diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh
index 76c00f8c250..d402827e6cc 100644
--- a/thirdparty/vars.sh
+++ b/thirdparty/vars.sh
@@ -228,6 +228,13 @@ LIBRDKAFKA_NAME=librdkafka-2.16.0.tar.gz
 LIBRDKAFKA_SOURCE=librdkafka-2.16.0
 LIBRDKAFKA_MD5SUM="6d2c62921241863d2bc95c58be27af6f"
 
+# MongoDB C Driver (libmongoc and libbson are released and built together).
+# 2.5.8 fixes malformed cursor namespaces and compressed-reply buffer leaks.
+MONGO_C_DRIVER_DOWNLOAD="https://github.com/mongodb/mongo-c-driver/releases/download/2.5.8/mongo-c-driver-2.5.8.tar.gz";
+MONGO_C_DRIVER_NAME=mongo-c-driver-2.5.8.tar.gz
+MONGO_C_DRIVER_SOURCE=mongo-c-driver-2.5.8
+MONGO_C_DRIVER_MD5SUM="e088246c56b3de5c658aff8e00f166ed"
+
 # zstd
 
ZSTD_DOWNLOAD="https://github.com/facebook/zstd/releases/download/v1.5.7/zstd-1.5.7.tar.gz";
 ZSTD_NAME=zstd-1.5.7.tar.gz
@@ -660,6 +667,7 @@ export TP_ARCHIVES=(
     'BRPC'
     'ROCKSDB'
     'CYRUS_SASL'
+    'MONGO_C_DRIVER'
     'LIBRDKAFKA'
     'FLATBUFFERS'
     'ARROW'


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

Reply via email to