Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2551] feat(catalog-jdbc-doris): Add a basic skeleton for Doris catalog #2554

Merged
merged 3 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ tasks {
dependsOn(
":catalogs:catalog-hive:copyLibAndConfig",
":catalogs:catalog-lakehouse-iceberg:copyLibAndConfig",
":catalogs:catalog-jdbc-doris:copyLibAndConfig",
":catalogs:catalog-jdbc-mysql:copyLibAndConfig",
":catalogs:catalog-jdbc-postgresql:copyLibAndConfig",
":catalogs:catalog-hadoop:copyLibAndConfig",
Expand Down
71 changes: 71 additions & 0 deletions catalogs/catalog-jdbc-doris/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
description = "catalog-jdbc-doris"

plugins {
`maven-publish`
id("java")
id("idea")
}

dependencies {
implementation(project(":api"))
implementation(project(":catalogs:catalog-jdbc-common"))
implementation(project(":common"))
implementation(project(":core"))

implementation(libs.bundles.log4j)
implementation(libs.commons.collections4)
implementation(libs.commons.lang3)
implementation(libs.guava)
implementation(libs.jsqlparser)
implementation(libs.slf4j.api)
}

tasks {
val runtimeJars by registering(Copy::class) {
from(configurations.runtimeClasspath)
into("build/libs")
}
val copyCatalogLibs by registering(Copy::class) {
dependsOn("jar", "runtimeJars")
from("build/libs")
into("$rootDir/distribution/package/catalogs/jdbc-doris/libs")
}

val copyCatalogConfig by registering(Copy::class) {
from("src/main/resources")
into("$rootDir/distribution/package/catalogs/jdbc-doris/conf")

include("jdbc-doris.conf")

exclude { details ->
details.file.isDirectory()
}
}

register("copyLibAndConfig", Copy::class) {
dependsOn(copyCatalogLibs, copyCatalogConfig)
}
}

tasks.test {
val skipUTs = project.hasProperty("skipTests")
if (skipUTs) {
// Only run integration tests
include("**/integration/**")
}

val skipITs = project.hasProperty("skipITs")
if (skipITs) {
// Exclude integration tests
exclude("**/integration/**")
} else {
dependsOn(tasks.jar)

val init = project.extra.get("initIntegrationTest") as (Test) -> Unit
init(this)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris;

import com.datastrato.gravitino.catalog.doris.converter.DorisColumnDefaultValueConverter;
import com.datastrato.gravitino.catalog.doris.converter.DorisExceptionConverter;
import com.datastrato.gravitino.catalog.doris.converter.DorisTypeConverter;
import com.datastrato.gravitino.catalog.doris.operation.DorisDatabaseOperations;
import com.datastrato.gravitino.catalog.doris.operation.DorisTableOperations;
import com.datastrato.gravitino.catalog.jdbc.JdbcCatalog;
import com.datastrato.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
import com.datastrato.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
import com.datastrato.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
import com.datastrato.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
import com.datastrato.gravitino.catalog.jdbc.operation.JdbcTableOperations;

/** Implementation of a Doris catalog in Gravitino. */
public class DorisCatalog extends JdbcCatalog {

@Override
public String shortName() {
return "jdbc-doris";
}

@Override
protected JdbcExceptionConverter createExceptionConverter() {
return new DorisExceptionConverter();
}

@Override
protected JdbcTypeConverter createJdbcTypeConverter() {
return new DorisTypeConverter();
}

@Override
protected JdbcDatabaseOperations createJdbcDatabaseOperations() {
return new DorisDatabaseOperations();
}

@Override
protected JdbcTableOperations createJdbcTableOperations() {
return new DorisTableOperations();
}

@Override
protected JdbcColumnDefaultValueConverter createJdbcColumnDefaultValueConverter() {
return new DorisColumnDefaultValueConverter();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris.converter;

import static com.datastrato.gravitino.rel.Column.DEFAULT_VALUE_NOT_SET;

import com.datastrato.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter;
import com.datastrato.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
import com.datastrato.gravitino.rel.expressions.Expression;

public class DorisColumnDefaultValueConverter extends JdbcColumnDefaultValueConverter {
@Override
public Expression toGravitino(
JdbcTypeConverter.JdbcTypeBean columnType,
String columnDefaultValue,
boolean isExpression,
boolean nullable) {
// TODO: add implementation for doris catalog
return DEFAULT_VALUE_NOT_SET;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris.converter;

import com.datastrato.gravitino.catalog.jdbc.converter.JdbcExceptionConverter;
import com.datastrato.gravitino.exceptions.GravitinoRuntimeException;
import java.sql.SQLException;

/** Exception converter to Gravitino exception for Doris. */
public class DorisExceptionConverter extends JdbcExceptionConverter {
@SuppressWarnings("FormatStringAnnotation")
@Override
public GravitinoRuntimeException toGravitinoException(SQLException se) {
// TODO: add implementation for doris catalog

return super.toGravitinoException(se);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris.converter;

import com.datastrato.gravitino.catalog.jdbc.converter.JdbcTypeConverter;
import com.datastrato.gravitino.rel.types.Type;
import com.datastrato.gravitino.rel.types.Types;

/** Type converter for Doris. */
public class DorisTypeConverter extends JdbcTypeConverter<String> {
// TODO: add implementation for doris catalog

@Override
public Type toGravitinoType(JdbcTypeBean typeBean) {
return Types.UnparsedType.of(typeBean.getTypeName());
}

@Override
public String fromGravitinoType(Type type) {
throw new IllegalArgumentException("unsupported type: " + type.simpleString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris.operation;

import com.datastrato.gravitino.catalog.jdbc.JdbcSchema;
import com.datastrato.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations;
import com.datastrato.gravitino.exceptions.NoSuchSchemaException;
import java.util.Map;

/** Database operations for Doris. */
public class DorisDatabaseOperations extends JdbcDatabaseOperations {
// TODO: add implementation for doris catalog

@Override
public JdbcSchema load(String databaseName) throws NoSuchSchemaException {
throw new UnsupportedOperationException();
}

@Override
protected String generateCreateDatabaseSql(
String databaseName, String comment, Map<String, String> properties) {
throw new UnsupportedOperationException();
}

@Override
protected String generateDropDatabaseSql(String databaseName, boolean cascade) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino.catalog.doris.operation;

import com.datastrato.gravitino.catalog.jdbc.JdbcColumn;
import com.datastrato.gravitino.catalog.jdbc.JdbcTable;
import com.datastrato.gravitino.catalog.jdbc.operation.JdbcTableOperations;
import com.datastrato.gravitino.rel.TableChange;
import com.datastrato.gravitino.rel.expressions.transforms.Transform;
import com.datastrato.gravitino.rel.indexes.Index;
import java.util.Map;

/** Table operations for Doris. */
public class DorisTableOperations extends JdbcTableOperations {
// TODO: add implementation for doris catalog

@Override
protected String generateCreateTableSql(
String tableName,
JdbcColumn[] columns,
String comment,
Map<String, String> properties,
Transform[] partitioning,
Index[] indexes) {
throw new UnsupportedOperationException();
}

@Override
protected String generateRenameTableSql(String oldTableName, String newTableName) {
throw new UnsupportedOperationException();
}

@Override
protected String generateDropTableSql(String tableName) {
throw new UnsupportedOperationException();
}

@Override
protected String generatePurgeTableSql(String tableName) {
throw new UnsupportedOperationException();
}

@Override
protected String generateAlterTableSql(
String databaseName, String tableName, TableChange... changes) {
throw new UnsupportedOperationException();
}

@Override
protected JdbcTable getOrCreateTable(
String databaseName, String tableName, JdbcTable lazyLoadCreateTable) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Copyright 2024 Datastrato Pvt Ltd.
# This software is licensed under the Apache License version 2.
#
com.datastrato.gravitino.catalog.doris.DorisCatalog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright 2024 Datastrato Pvt Ltd.
# This software is licensed under the Apache License version 2.
#
# jdbc-url = jdbc:mysql://localhost:9030/
# jdbc-user = strato
# jdbc-password = strato
# jdbc-driver = com.mysql.jdbc.Driver
7 changes: 6 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ include("api", "common", "core", "meta", "server", "integration-test", "server-c
include("catalogs:bundled-catalog")
include("catalogs:catalog-hive")
include("catalogs:catalog-lakehouse-iceberg")
include("catalogs:catalog-jdbc-common", "catalogs:catalog-jdbc-mysql", "catalogs:catalog-jdbc-postgresql")
include(
"catalogs:catalog-jdbc-common",
"catalogs:catalog-jdbc-doris",
"catalogs:catalog-jdbc-mysql",
"catalogs:catalog-jdbc-postgresql"
)
include("catalogs:catalog-hadoop")
include("catalogs:catalog-messaging-kafka")
include("clients:client-java", "clients:client-java-runtime")
Expand Down
Loading