-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a basic skeleton for Doris catalog.
- Loading branch information
1 parent
ffb80e7
commit e2c4cda
Showing
11 changed files
with
312 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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) | ||
|
||
testImplementation(project(":catalogs:catalog-jdbc-common", "testArtifacts")) | ||
testImplementation(project(":clients:client-java")) | ||
testImplementation(project(":integration-test-common", "testArtifacts")) | ||
testImplementation(project(":server")) | ||
testImplementation(project(":server-common")) | ||
|
||
testImplementation(libs.commons.lang3) | ||
testImplementation(libs.guava) | ||
testImplementation(libs.junit.jupiter.api) | ||
testImplementation(libs.junit.jupiter.params) | ||
testImplementation(libs.mysql.driver) | ||
testImplementation(libs.testcontainers) | ||
testImplementation(libs.testcontainers.mysql) | ||
|
||
testRuntimeOnly(libs.junit.jupiter.engine) | ||
} | ||
|
||
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) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...catalog-jdbc-doris/src/main/java/com/datastrato/gravitino/catalog/doris/DorisCatalog.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/com/datastrato/gravitino/catalog/doris/converter/DorisColumnDefaultValueConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...c/main/java/com/datastrato/gravitino/catalog/doris/converter/DorisExceptionConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...is/src/main/java/com/datastrato/gravitino/catalog/doris/converter/DorisTypeConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...c/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisDatabaseOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
.../src/main/java/com/datastrato/gravitino/catalog/doris/operation/DorisTableOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...-jdbc-doris/src/main/resources/META-INF/services/com.datastrato.gravitino.CatalogProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
8 changes: 8 additions & 0 deletions
8
catalogs/catalog-jdbc-doris/src/main/resources/jdbc-doris.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters