-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature(jdbc-catalog):Add code skeleton for oceanbase-ce jdbc catalog (…
…#4918) ### What changes were proposed in this pull request? - add catalog-jdbc-oceanbase module - add code skeleton for oceanbase-ce jdbc catalog ### Why are the changes needed? Fix: #4916 ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? build pass. tests will be added in implementation PRs
- Loading branch information
Showing
12 changed files
with
580 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
description = "catalog-jdbc-oceanbase" | ||
|
||
plugins { | ||
`maven-publish` | ||
id("java") | ||
id("idea") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":api")) { | ||
exclude(group = "*") | ||
} | ||
implementation(project(":catalogs:catalog-common")) { | ||
exclude(group = "*") | ||
} | ||
implementation(project(":catalogs:catalog-jdbc-common")) { | ||
exclude(group = "*") | ||
} | ||
implementation(project(":common")) { | ||
exclude(group = "*") | ||
} | ||
implementation(project(":core")) { | ||
exclude(group = "*") | ||
} | ||
|
||
implementation(libs.bundles.log4j) | ||
implementation(libs.commons.collections4) | ||
implementation(libs.commons.lang3) | ||
implementation(libs.guava) | ||
} |
84 changes: 84 additions & 0 deletions
84
...jdbc-oceanbase/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalog.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,84 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase; | ||
|
||
import java.util.Map; | ||
import org.apache.gravitino.catalog.jdbc.JdbcCatalog; | ||
import org.apache.gravitino.catalog.jdbc.JdbcCatalogOperations; | ||
import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter; | ||
import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter; | ||
import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter; | ||
import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations; | ||
import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations; | ||
import org.apache.gravitino.catalog.oceanbase.converter.OceanBaseColumnDefaultValueConverter; | ||
import org.apache.gravitino.catalog.oceanbase.converter.OceanBaseExceptionConverter; | ||
import org.apache.gravitino.catalog.oceanbase.converter.OceanBaseTypeConverter; | ||
import org.apache.gravitino.catalog.oceanbase.operation.OceanBaseDatabaseOperations; | ||
import org.apache.gravitino.catalog.oceanbase.operation.OceanBaseTableOperations; | ||
import org.apache.gravitino.connector.CatalogOperations; | ||
import org.apache.gravitino.connector.capability.Capability; | ||
|
||
/** Implementation of a OceanBase catalog in Apache Gravitino. */ | ||
public class OceanBaseCatalog extends JdbcCatalog { | ||
|
||
@Override | ||
public String shortName() { | ||
return "jdbc-oceanbase"; | ||
} | ||
|
||
@Override | ||
protected CatalogOperations newOps(Map<String, String> config) { | ||
return new JdbcCatalogOperations( | ||
createExceptionConverter(), | ||
createJdbcTypeConverter(), | ||
createJdbcDatabaseOperations(), | ||
createJdbcTableOperations(), | ||
createJdbcColumnDefaultValueConverter()); | ||
} | ||
|
||
@Override | ||
public Capability newCapability() { | ||
return new OceanBaseCatalogCapability(); | ||
} | ||
|
||
@Override | ||
protected JdbcExceptionConverter createExceptionConverter() { | ||
return new OceanBaseExceptionConverter(); | ||
} | ||
|
||
@Override | ||
protected JdbcTypeConverter createJdbcTypeConverter() { | ||
return new OceanBaseTypeConverter(); | ||
} | ||
|
||
@Override | ||
protected JdbcDatabaseOperations createJdbcDatabaseOperations() { | ||
return new OceanBaseDatabaseOperations(); | ||
} | ||
|
||
@Override | ||
protected JdbcTableOperations createJdbcTableOperations() { | ||
return new OceanBaseTableOperations(); | ||
} | ||
|
||
@Override | ||
protected JdbcColumnDefaultValueConverter createJdbcColumnDefaultValueConverter() { | ||
return new OceanBaseColumnDefaultValueConverter(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...base/src/main/java/org/apache/gravitino/catalog/oceanbase/OceanBaseCatalogCapability.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 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase; | ||
|
||
import org.apache.gravitino.connector.capability.Capability; | ||
import org.apache.gravitino.connector.capability.CapabilityResult; | ||
|
||
public class OceanBaseCatalogCapability implements Capability { | ||
|
||
/** | ||
* Regular expression explanation: ^[\w\p{L}-$/=]{1,64}$ | ||
* | ||
* <p>^ - Start of the string | ||
* | ||
* <p>[\w\p{L}-$/=]{1,64} - Consist of 1 to 64 characters of letters (both cases), digits, | ||
* underscores, any kind of letter from any language, hyphens, dollar signs, slashes or equal | ||
* signs | ||
* | ||
* <p>\w - matches [a-zA-Z0-9_] | ||
* | ||
* <p>\p{L} - matches any kind of letter from any language | ||
* | ||
* <p>$ - End of the string | ||
*/ | ||
public static final String OCEANBASE_NAME_PATTERN = "^[\\w\\p{L}-$/=]{1,64}$"; | ||
|
||
@Override | ||
public CapabilityResult specificationOnName(Scope scope, String name) { | ||
if (!name.matches(OCEANBASE_NAME_PATTERN)) { | ||
return CapabilityResult.unsupported( | ||
String.format("The %s name '%s' is illegal.", scope, name)); | ||
} | ||
return CapabilityResult.SUPPORTED; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...rg/apache/gravitino/catalog/oceanbase/converter/OceanBaseColumnDefaultValueConverter.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,36 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase.converter; | ||
|
||
import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter; | ||
import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter; | ||
import org.apache.gravitino.exceptions.GravitinoRuntimeException; | ||
import org.apache.gravitino.rel.expressions.Expression; | ||
|
||
public class OceanBaseColumnDefaultValueConverter extends JdbcColumnDefaultValueConverter { | ||
|
||
@Override | ||
public Expression toGravitino( | ||
JdbcTypeConverter.JdbcTypeBean type, | ||
String columnDefaultValue, | ||
boolean isExpression, | ||
boolean nullable) { | ||
throw new GravitinoRuntimeException("Not implemented yet."); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...in/java/org/apache/gravitino/catalog/oceanbase/converter/OceanBaseExceptionConverter.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,33 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase.converter; | ||
|
||
import java.sql.SQLException; | ||
import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter; | ||
import org.apache.gravitino.exceptions.GravitinoRuntimeException; | ||
|
||
/** Exception converter to Apache Gravitino exception for OceanBase. */ | ||
public class OceanBaseExceptionConverter extends JdbcExceptionConverter { | ||
|
||
@SuppressWarnings("FormatStringAnnotation") | ||
@Override | ||
public GravitinoRuntimeException toGravitinoException(SQLException se) { | ||
return new GravitinoRuntimeException("Not implemented yet."); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...rc/main/java/org/apache/gravitino/catalog/oceanbase/converter/OceanBaseTypeConverter.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,40 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase.converter; | ||
|
||
import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter; | ||
import org.apache.gravitino.exceptions.GravitinoRuntimeException; | ||
import org.apache.gravitino.rel.types.Type; | ||
|
||
/** Type converter for OceanBase. */ | ||
public class OceanBaseTypeConverter extends JdbcTypeConverter { | ||
|
||
// More data types will be added. | ||
static final String TINYINT = "tinyint"; | ||
|
||
@Override | ||
public Type toGravitino(JdbcTypeBean typeBean) { | ||
throw new GravitinoRuntimeException("Not implemented yet."); | ||
} | ||
|
||
@Override | ||
public String fromGravitino(Type type) { | ||
throw new GravitinoRuntimeException("Not implemented yet."); | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
...in/java/org/apache/gravitino/catalog/oceanbase/operation/OceanBaseDatabaseOperations.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,65 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.gravitino.catalog.oceanbase.operation; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import org.apache.gravitino.catalog.jdbc.JdbcSchema; | ||
import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations; | ||
import org.apache.gravitino.exceptions.NoSuchSchemaException; | ||
|
||
/** Database operations for OceanBase. */ | ||
public class OceanBaseDatabaseOperations extends JdbcDatabaseOperations { | ||
|
||
public static final Set<String> SYS_OCEANBASE_DATABASE_NAMES = createSysOceanBaseDatabaseNames(); | ||
|
||
private static Set<String> createSysOceanBaseDatabaseNames() { | ||
Set<String> set = new HashSet<>(); | ||
set.add("information_schema"); | ||
set.add("mysql"); | ||
set.add("sys"); | ||
set.add("oceanbase"); | ||
return Collections.unmodifiableSet(set); | ||
} | ||
|
||
@Override | ||
public String generateCreateDatabaseSql( | ||
String databaseName, String comment, Map<String, String> properties) { | ||
|
||
throw new UnsupportedOperationException("Not implemented yet."); | ||
} | ||
|
||
@Override | ||
public String generateDropDatabaseSql(String databaseName, boolean cascade) { | ||
throw new UnsupportedOperationException("Not implemented yet."); | ||
} | ||
|
||
@Override | ||
public JdbcSchema load(String databaseName) throws NoSuchSchemaException { | ||
throw new UnsupportedOperationException("Not implemented yet."); | ||
} | ||
|
||
@Override | ||
protected boolean isSystemDatabase(String dbName) { | ||
return SYS_OCEANBASE_DATABASE_NAMES.contains(dbName.toLowerCase(Locale.ROOT)); | ||
} | ||
} |
Oops, something went wrong.