RepositoryJava
apache

apache/doris-spark-connector

Spark Connector for Apache Doris

107stars
130forks
31issues
2views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: dbms

#1 Repository of the month

1
TINIX TRENDING·Topic: doris

#1 Repository of the month

1
TINIX TRENDING·Topic: data-warehousing

#1 Repository of the month

Spark Connector for Apache Doris

License Join the Doris Community at Slack

Spark Doris Connector

More information about compilation and usage, please visit Spark Doris Connector

License

Apache License, Version 2.0

How to Build

You need to copy customer_env.sh.tpl to customer_env.sh before build and you need to configure it before build.

git clone git@github.com:apache/doris-spark-connector.git
cd doris-spark-connector/spark-doris-connector
./build.sh

QuickStart

  1. download and compile Spark Doris Connector from https://github.com/apache/doris-spark-connector, we suggest compile Spark Doris Connector by Doris official image。
$ docker pull apache/doris:build-env-ldb-toolchain-latest
  1. the result of compile jar is like:spark-doris-connector-3.1_2.12-1.0.0-SNAPSHOT.jar

  2. download spark for https://spark.apache.org/downloads.html .if in china there have a good choice of tencent link https://mirrors.cloud.tencent.com/apache/spark/spark-3.1.2/

#download
wget https://mirrors.cloud.tencent.com/apache/spark/spark-3.1.2/spark-3.1.2-bin-hadoop3.2.tgz
#decompression
tar -xzvf spark-3.1.2-bin-hadoop3.2.tgz
  1. config Spark environment
vim /etc/profile
export SPARK_HOME=/your_parh/spark-3.1.2-bin-hadoop3.2
export PATH=$PATH:$SPARK_HOME/bin
source /etc/profile
  1. copy spark-doris-connector-3.1_2.12-1.0.0-SNAPSHOT.jar to spark jars directory。
cp /your_path/spark-doris-connector/target/spark-doris-connector-3.1_2.12-1.0.0-SNAPSHOT.jar  $SPARK_HOME/jars
  1. created doris database and table。

    create database mongo_doris;
    use mongo_doris;
    CREATE TABLE data_sync_test_simple
     (
             _id VARCHAR(32) DEFAULT '',
             id VARCHAR(32) DEFAULT '',
             user_name VARCHAR(32) DEFAULT '',
             member_list VARCHAR(32) DEFAULT ''
     )
     DUPLICATE KEY(_id)
     DISTRIBUTED BY HASH(_id) BUCKETS 10
     PROPERTIES("replication_num" = "1");
    INSERT INTO data_sync_test_simple VALUES ('1','1','alex','123');
    
    1. Input this coed in spark-shell.
import org.apache.doris.spark._
val dorisSparkRDD = sc.dorisRDD(
  tableIdentifier = Some("mongo_doris.data_sync_test"),
  cfg = Some(Map(
    "doris.fenodes" -> "127.0.0.1:8030",
    "doris.request.auth.user" -> "root",
    "doris.request.auth.password" -> ""
  ))
)
dorisSparkRDD.collect()
  • mongo_doris:doris database name
  • data_sync_test:doris table mame.
  • doris.fenodes:doris FE IP:http_port
  • doris.request.auth.user:doris user name.
  • doris.request.auth.password:doris password
  1. if Spark is Cluster model,upload Jar to HDFS,add doris-spark-connector jar HDFS URL in spark.yarn.jars.
spark.yarn.jars=hdfs:///spark-jars/doris-spark-connector-3.1.2-2.12-1.0.0.jar

Link:https://github.com/apache/doris/discussions/9486

  1. in pyspark,input this code in pyspark shell command.
dorisSparkDF = spark.read.format("doris")
.option("doris.table.identifier", "mongo_doris.data_sync_test")
.option("doris.fenodes", "127.0.0.1:8030")
.option("user", "root")
.option("password", "")
.load()
# show 5 lines data 
dorisSparkDF.show(5)

type convertion for writing to doris using arrow

dorisspark
BOOLEANBooleanType
TINYINTByteType
SMALLINTShortType
INTIntegerType
BIGINTLongType
LARGEINTStringType
FLOATFloatType
DOUBLEDoubleType
DECIMAL(M,D)DecimalType(M,D)
DATEDateType
DATETIMETimestampType
CHAR(L)StringType
VARCHAR(L)StringType
STRINGStringType
ARRAYARRAY
MAPMAP
STRUCTSTRUCT

Report issues or submit pull request

If you find any bugs, feel free to file a GitHub issue or fix it by submitting a pull request.

Contact Us

Contact us through the following mailing list.

NameScope
dev@doris.apache.orgDevelopment-related discussionsSubscribeUnsubscribeArchives

Similar Projects

Discover other similar projects and AI models.

RepositoryJava
apache/doris-flink-connector

Flink Connector for Apache Doris

383
Nov 16, 2026
RepositoryJava
apache/doris-manager

Cluster manager for Apache Doris

193
Nov 16, 2023
RepositoryC++
ClickHouse/ClickHouse

ClickHouse® is a real-time analytics database management system

51.3k
Dec 1, 2026
RepositoryMDX
apache/doris-website

Apache Doris Website

138
Nov 27, 2026
RepositoryJava
StarRocks/starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.

12.3k
Dec 1, 2026
RepositoryC
apache/cloudberry

One advanced and mature open-source MPP (Massively Parallel Processing) database. Open source alternative to Greenplum Database.

1.5k
Nov 28, 2026
RepositoryC++
serenedb/serenedb

The First Real-Time Search Analytics Database

1.1k
Dec 1, 2026
RepositoryPython
apache/superset

Apache Superset is a Data Visualization and Data Exploration Platform

75.7k
Nov 29, 2026
RepositoryTypeScript
apache/echarts

Apache ECharts is a powerful, interactive charting and data visualization library for browser

67.8k
Nov 25, 2026