-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#777] feat(jdbc-mysql): Support for mysql catalog in Gravitino.
- Loading branch information
Showing
20 changed files
with
1,405 additions
and
24 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
api/src/main/java/com/datastrato/gravitino/exceptions/NoSuchColumnException.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,17 @@ | ||
/* | ||
* Copyright 2023 Datastrato. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.exceptions; | ||
|
||
/** Exception thrown when a column with specified name is not existed. */ | ||
public class NoSuchColumnException extends NotFoundException { | ||
|
||
public NoSuchColumnException(String message) { | ||
super(message); | ||
} | ||
|
||
public NoSuchColumnException(String message, Throwable cause) { | ||
super(message, cause); | ||
} | ||
} |
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
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
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
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,31 @@ | ||
/* | ||
* Copyright 2023 Datastrato. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
description = "catalog-jdbc-mysql" | ||
|
||
plugins { | ||
`maven-publish` | ||
id("java") | ||
id("idea") | ||
id("com.diffplug.spotless") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":common")) | ||
implementation(project(":core")) | ||
implementation(project(":api")) | ||
implementation(project(":catalogs:catalog-jdbc-common")) | ||
implementation(libs.bundles.log4j) | ||
implementation(libs.commons.lang3) | ||
implementation(libs.commons.collections4) | ||
implementation(libs.jsqlparser) | ||
implementation(libs.substrait.java.core) { | ||
exclude("com.fasterxml.jackson.core") | ||
exclude("com.fasterxml.jackson.datatype") | ||
exclude("com.fasterxml.jackson.dataformat") | ||
exclude("com.google.protobuf") | ||
exclude("com.google.code.findbugs") | ||
exclude("org.slf4j") | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...catalog-jdbc-mysql/src/main/java/com/datastrato/gravitino/catalog/mysql/MysqlCatalog.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,44 @@ | ||
/* | ||
* Copyright 2023 Datastrato. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog.mysql; | ||
|
||
import com.datastrato.gravitino.catalog.jdbc.JdbcCatalog; | ||
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; | ||
import com.datastrato.gravitino.catalog.mysql.converter.MysqlExceptionConverter; | ||
import com.datastrato.gravitino.catalog.mysql.converter.MysqlTypeConverter; | ||
import com.datastrato.gravitino.catalog.mysql.operation.MysqlDatabaseOperations; | ||
import com.datastrato.gravitino.catalog.mysql.operation.MysqlTableOperations; | ||
|
||
/** Implementation of an Jdbc catalog in Gravitino. */ | ||
public abstract class MysqlCatalog extends JdbcCatalog { | ||
|
||
@Override | ||
public String shortName() { | ||
return "mysql"; | ||
} | ||
|
||
@Override | ||
protected JdbcExceptionConverter createExceptionConverter() { | ||
return new MysqlExceptionConverter(); | ||
} | ||
|
||
@Override | ||
protected JdbcTypeConverter createJdbcTypeConverter() { | ||
return new MysqlTypeConverter(); | ||
} | ||
|
||
@Override | ||
protected JdbcDatabaseOperations createJdbcDatabaseOperations() { | ||
return new MysqlDatabaseOperations(); | ||
} | ||
|
||
@Override | ||
protected JdbcTableOperations createJdbcTableOperations() { | ||
return new MysqlTableOperations(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...c/main/java/com/datastrato/gravitino/catalog/mysql/converter/MysqlExceptionConverter.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,34 @@ | ||
/* | ||
* Copyright 2023 Datastrato. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.catalog.mysql.converter; | ||
|
||
import com.datastrato.gravitino.catalog.jdbc.converter.JdbcExceptionConverter; | ||
import com.datastrato.gravitino.exceptions.GravitinoRuntimeException; | ||
import com.datastrato.gravitino.exceptions.NoSuchSchemaException; | ||
import com.datastrato.gravitino.exceptions.NoSuchTableException; | ||
import com.datastrato.gravitino.exceptions.SchemaAlreadyExistsException; | ||
import com.datastrato.gravitino.exceptions.TableAlreadyExistsException; | ||
import java.sql.SQLException; | ||
|
||
/** Exception converter to gravitino exception for MySQL. */ | ||
public class MysqlExceptionConverter extends JdbcExceptionConverter { | ||
|
||
@Override | ||
public GravitinoRuntimeException toGravitinoException(SQLException se) { | ||
switch (se.getErrorCode()) { | ||
case 1007: | ||
return new SchemaAlreadyExistsException(se.getMessage(), se); | ||
case 1050: | ||
return new TableAlreadyExistsException(se.getMessage(), se); | ||
case 1008: | ||
return new NoSuchSchemaException(se.getMessage(), se); | ||
case 1146: | ||
case 1051: | ||
return new NoSuchTableException(se.getMessage(), se); | ||
default: | ||
return new GravitinoRuntimeException(se.getMessage(), se); | ||
} | ||
} | ||
} |
Oops, something went wrong.