百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
M

marble

> 编程语言
开源

基于 Apache Calcite 的高性能内存 Hive SQL 引擎

196 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

基于 Apache Calcite 的高性能内存 Hive SQL 引擎

Marble is a high performance in-memory hive sql engine based on Apache Calcite.
It can help you to migrate hive sql scripts to a real-time computing system.
It also provides a convenient Table API to help you to build custom SQL engines.

You may want another similar project: direct-spark-sql

Build and run tests

Requirements

  • Java 1.8 as a build JDK
  • Maven

1.build marble

bash
cd marble
mvn clean install -DskipTests

(Optional)
if you need modify the patches of Calcite, build calcite-patch project first

bash
git clone https://github.com/51nb/calcite-patch.git
cd calcite-patch
mvn clean install -DskipTests

In the long term,we hope to merge the patches to Calcite finally.

2.import marble project into IDE, but please don't import calcite-patch as a submodule of marble project

3.run the test TableEnvTest and HiveTableEnvTest

Usage

Maven dependency

…

API Overview

TableEnv.enableSqlPlanCacheSize(200);

TableEnv tableEnv = HiveTableEnv.getTableEnv();

DataTable t1 = tableEnv.fromJavaPojoList(pojoList);
DataTable t2 = tableEnv.fromJdbcResultSet(resultSet);
DataTable t3=tableEnv.fromRowListWithSqlTypeMap(rowList,sqlTypeMap);

tableEnv.addSubSchema("test");
tableEnv.registerTable("test","t1",t1);
tableEnv.registerTable("test","t2", t2);
DataTable queryResult = tableEnv.sqlQuery("select * from test.t1 join test.t2 on t1.id=t2.id");
List> rowList=queryResult.toMapList();

It's recommended to enable plan cache for the same sql query:

TableEnv.enableSqlPlanCacheSize(200);

TableEnv is the main table api to execute sql queries on a dataSet.
It can be used to:

  • convert a java pojo List or jdbc ResultSet to a DataTable
  • register a DataTable in TableEnv's catalog
  • add subSchemas and customized functions in TableEnv's catalog
  • execute a sql query to get the result DataTable

The TableEnv supports Calcite's sql dialect by default,see it's sql reference.
The goal of HiveTableEnv is to support hive sql as far as possible,developers can aslo use a TableConfig to create a new TableEnv to support other sql dialects(MysqlTableEnv,PostgreTableEnv ..etc).

Supported hive sql features

  • specific keywords and operators
  • all of UDF,UDAF
  • part of UDTF
  • implicit type casting
  • load customized UDF,UDAF by package name
    HiveTableEnv.registerHiveFunctionPackages("com.u51.data.hive.udf"); 

Benchmark

There're some benchmark tests in the benchmark module,it compares flink,spark and marble on some simple sql queries.

Design

It shows how marble customized calcite in the sql processing flow:

You can find more details from calcite-patch's commit history.Now Marble uses calcite 1.18.0.

The main type mapping between calcite and hive is:

CalciteSqlType JavaStorageType HiveObjectInspector
BIGINT Long LongObjectInspector
INTEGER Int IntObjectInspector
DOUBLE Double DoubleObjectInspectors
DECIMAL BigDecimal HiveDecimalObjectInspector
VARCHAR String StringObjectInspector
DATE Int DateObjectInspector
TIMESTAMP Long TimestampObjectInspector
ARRAY List StandardListObjectInspector
...... ...... ......

Roadmap

  • improve compatibility with hive sql.(high priority)
  • submit patches to Calcite,make it easy to upgrade calcite-core, some related issues:CALCITE-2282,CALCITE-2973,CALCITE-2992.(high priority)
  • implements UDTF in a generic way.(high priority)
  • constant folded for hive udf.(low priority)
  • use a customized sql Planner to replace the default PlannerImpl.(low priority)
  • TPC-DS queries with a customized scale.(low priority)
  • vectorized udf execution.(experimental)
  • distributed broadcast join.(experimental)
  • cost based optimizer.(experimental)

More issues see issues.

Contributing

Welcome contributions. Please use the Calcite-idea-code-style.xml under the marble directory to reformat code, and ensure that the validation of maven checker-style plugin is success after source code building.

License

This library is distributed under terms of Apache 2 License

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言