This is an automated email from the ASF dual-hosted git repository. yuqi4733 pushed a commit to branch internal-main in repository https://gitbox.apache.org/repos/asf/gravitino.git
commit 8954fcc88d9a9a62f61acc7974869fc2499115db Author: geyanggang <[email protected]> AuthorDate: Fri Feb 6 16:55:39 2026 +0800 [#91]feat(bigquery-catalog): Add BigQuery catalog skeleton. --- build.gradle.kts | 1 + catalogs/catalog-jdbc-bigquery/build.gradle.kts | 100 ++++++++++++++++++++ .../catalog/bigquery/BigQueryCatalog.java | 90 ++++++++++++++++++ .../bigquery/BigQueryCatalogCapability.java | 73 +++++++++++++++ .../BigQueryCatalogPropertiesMetadata.java | 44 +++++++++ .../bigquery/BigQuerySchemaPropertiesMetadata.java | 33 +++++++ .../bigquery/BigQueryTablePropertiesMetadata.java | 33 +++++++ .../BigQueryColumnDefaultValueConverter.java | 37 ++++++++ .../converter/BigQueryExceptionConverter.java | 34 +++++++ .../bigquery/converter/BigQueryTypeConverter.java | 37 ++++++++ .../operation/BigQueryDatabaseOperations.java | 57 ++++++++++++ .../operation/BigQueryTableOperations.java | 101 +++++++++++++++++++++ .../services/org.apache.gravitino.CatalogProvider | 19 ++++ .../src/main/resources/jdbc-bigquery.conf | 29 ++++++ settings.gradle.kts | 1 + 15 files changed, 689 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index e2b75f13f2..808d4660ce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1049,6 +1049,7 @@ tasks { dependsOn( ":catalogs:catalog-fileset:copyLibAndConfig", ":catalogs:catalog-hive:copyLibAndConfig", + ":catalogs:catalog-jdbc-bigquery:copyLibAndConfig", ":catalogs:catalog-jdbc-doris:copyLibAndConfig", ":catalogs:catalog-jdbc-mysql:copyLibAndConfig", ":catalogs:catalog-jdbc-oceanbase:copyLibAndConfig", diff --git a/catalogs/catalog-jdbc-bigquery/build.gradle.kts b/catalogs/catalog-jdbc-bigquery/build.gradle.kts new file mode 100644 index 0000000000..7b04ae9330 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/build.gradle.kts @@ -0,0 +1,100 @@ +/* + * 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-bigquery" + +plugins { + `maven-publish` + id("java") + id("idea") +} + +dependencies { + implementation(project(":api")) { + 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.lang3) + implementation(libs.guava) + + 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.junit.jupiter.api) + testImplementation(libs.junit.jupiter.params) + + 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") { + exclude("guava-*.jar") + exclude("log4j-*.jar") + exclude("slf4j-*.jar") + } + into("$rootDir/distribution/package/catalogs/jdbc-bigquery/libs") + } + + val copyCatalogConfig by registering(Copy::class) { + from("src/main/resources") + into("$rootDir/distribution/package/catalogs/jdbc-bigquery/conf") + include("jdbc-bigquery.conf") + exclude { details -> + details.file.isDirectory() + } + fileMode = 0b111101101 + } + + register("copyLibAndConfig", Copy::class) { + dependsOn(copyCatalogLibs, copyCatalogConfig) + } +} + +tasks.test { + val skipITs = project.hasProperty("skipITs") + if (skipITs) { + // Exclude integration tests + exclude("**/integration/**") + } else { + dependsOn(tasks.jar) + } +} + +tasks.getByName("generateMetadataFileForMavenJavaPublication") { + dependsOn("runtimeJars") +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalog.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalog.java new file mode 100644 index 0000000000..bb47ddc209 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalog.java @@ -0,0 +1,90 @@ +/* + * 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.bigquery; + +import org.apache.gravitino.catalog.bigquery.converter.BigQueryColumnDefaultValueConverter; +import org.apache.gravitino.catalog.bigquery.converter.BigQueryExceptionConverter; +import org.apache.gravitino.catalog.bigquery.converter.BigQueryTypeConverter; +import org.apache.gravitino.catalog.bigquery.operation.BigQueryDatabaseOperations; +import org.apache.gravitino.catalog.bigquery.operation.BigQueryTableOperations; +import org.apache.gravitino.catalog.jdbc.JdbcCatalog; +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.connector.PropertiesMetadata; +import org.apache.gravitino.connector.capability.Capability; + +/** Implementation of a BigQuery catalog in Apache Gravitino. */ +public class BigQueryCatalog extends JdbcCatalog { + + public static final BigQueryTablePropertiesMetadata BIGQUERY_TABLE_PROPERTIES_META = + new BigQueryTablePropertiesMetadata(); + + @Override + public String shortName() { + return "jdbc-bigquery"; + } + + @Override + public Capability newCapability() { + return new BigQueryCatalogCapability(); + } + + @Override + public PropertiesMetadata catalogPropertiesMetadata() throws UnsupportedOperationException { + return new BigQueryCatalogPropertiesMetadata(); + } + + @Override + public PropertiesMetadata schemaPropertiesMetadata() throws UnsupportedOperationException { + return new BigQuerySchemaPropertiesMetadata(); + } + + @Override + public PropertiesMetadata tablePropertiesMetadata() throws UnsupportedOperationException { + return BIGQUERY_TABLE_PROPERTIES_META; + } + + @Override + protected JdbcExceptionConverter createExceptionConverter() { + return new BigQueryExceptionConverter(); + } + + @Override + protected JdbcTypeConverter createJdbcTypeConverter() { + return new BigQueryTypeConverter(); + } + + @Override + protected JdbcDatabaseOperations createJdbcDatabaseOperations() { + return new BigQueryDatabaseOperations(); + } + + @Override + protected JdbcTableOperations createJdbcTableOperations() { + return new BigQueryTableOperations(); + } + + @Override + protected JdbcColumnDefaultValueConverter createJdbcColumnDefaultValueConverter() { + return new BigQueryColumnDefaultValueConverter(); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogCapability.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogCapability.java new file mode 100644 index 0000000000..137719a2dc --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogCapability.java @@ -0,0 +1,73 @@ +/* + * 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.bigquery; + +import java.util.Set; +import org.apache.gravitino.connector.capability.Capability; +import org.apache.gravitino.connector.capability.CapabilityResult; + +public class BigQueryCatalogCapability implements Capability { + /** + * Regular expression explanation: ^[a-zA-Z0-9_]{1,1024}$ + * + * <p>^ - Start of the string + * + * <p>[a-zA-Z0-9_]{1,1024} - Consist of 1 to 1024 characters of letters (both cases), digits, and + * underscores + * + * <p>$ - End of the string + * + * <p>BigQuery dataset and table names must contain only letters (a-z, A-Z), numbers (0-9), or + * underscores (_). Names must start with a letter or underscore. + */ + public static final String BIGQUERY_NAME_PATTERN = "^[a-zA-Z_][a-zA-Z0-9_]{0,1023}$"; + + /** Reserved dataset names in BigQuery that cannot be used for user-defined datasets. */ + private static final Set<String> BIGQUERY_RESERVED_DATASETS = + Set.of("information_schema", "sys", "INFORMATION_SCHEMA", "SYS"); + + /** Reserved table names in BigQuery that cannot be used for user-defined tables. */ + private static final Set<String> BIGQUERY_RESERVED_TABLES = + Set.of("__TABLES__", "__TABLES_SUMMARY__", "__PARTITIONS__", "__PARTITIONS_SUMMARY__"); + + @Override + public CapabilityResult specificationOnName(Scope scope, String name) { + // Check basic naming pattern + if (!name.matches(BIGQUERY_NAME_PATTERN)) { + return CapabilityResult.unsupported( + String.format( + "The %s name '%s' is illegal. BigQuery names must start with a letter or underscore, " + + "contain only letters, numbers, or underscores, and be 1-1024 characters long.", + scope, name)); + } + + // Check reserved names + if (scope == Scope.SCHEMA && BIGQUERY_RESERVED_DATASETS.contains(name)) { + return CapabilityResult.unsupported( + String.format("The %s name '%s' is reserved and cannot be used.", scope, name)); + } + + if (scope == Scope.TABLE && BIGQUERY_RESERVED_TABLES.contains(name)) { + return CapabilityResult.unsupported( + String.format("The %s name '%s' is reserved and cannot be used.", scope, name)); + } + + return CapabilityResult.SUPPORTED; + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogPropertiesMetadata.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogPropertiesMetadata.java new file mode 100644 index 0000000000..c1df1b8b42 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryCatalogPropertiesMetadata.java @@ -0,0 +1,44 @@ +/* + * 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.bigquery; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import org.apache.gravitino.catalog.jdbc.JdbcCatalogPropertiesMetadata; +import org.apache.gravitino.connector.PropertyEntry; + +/** Properties metadata for BigQuery catalog. */ +public class BigQueryCatalogPropertiesMetadata extends JdbcCatalogPropertiesMetadata { + + private static final Map<String, PropertyEntry<?>> BIGQUERY_CATALOG_PROPERTY_ENTRIES = + ImmutableMap.<String, PropertyEntry<?>>builder() + .put( + "project-id", + PropertyEntry.stringRequiredPropertyEntry( + "project-id", + "Google Cloud Project ID", + false /* immutable */, + false /* hidden */)) + .build(); + + @Override + protected Map<String, PropertyEntry<?>> specificPropertyEntries() { + return BIGQUERY_CATALOG_PROPERTY_ENTRIES; + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQuerySchemaPropertiesMetadata.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQuerySchemaPropertiesMetadata.java new file mode 100644 index 0000000000..291c195d79 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQuerySchemaPropertiesMetadata.java @@ -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.bigquery; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import org.apache.gravitino.connector.BasePropertiesMetadata; +import org.apache.gravitino.connector.PropertyEntry; + +/** BigQuery schema (dataset) properties metadata. */ +public class BigQuerySchemaPropertiesMetadata extends BasePropertiesMetadata { + + @Override + protected Map<String, PropertyEntry<?>> specificPropertyEntries() { + return ImmutableMap.of(); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryTablePropertiesMetadata.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryTablePropertiesMetadata.java new file mode 100644 index 0000000000..2222ec1cbd --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/BigQueryTablePropertiesMetadata.java @@ -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.bigquery; + +import com.google.common.collect.ImmutableMap; +import java.util.Map; +import org.apache.gravitino.catalog.jdbc.JdbcTablePropertiesMetadata; +import org.apache.gravitino.connector.PropertyEntry; + +/** BigQuery table properties metadata. */ +public class BigQueryTablePropertiesMetadata extends JdbcTablePropertiesMetadata { + + @Override + protected Map<String, PropertyEntry<?>> specificPropertyEntries() { + return ImmutableMap.of(); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryColumnDefaultValueConverter.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryColumnDefaultValueConverter.java new file mode 100644 index 0000000000..8e1da4f4a7 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryColumnDefaultValueConverter.java @@ -0,0 +1,37 @@ +/* + * 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.bigquery.converter; + +import org.apache.commons.lang3.NotImplementedException; +import org.apache.gravitino.catalog.jdbc.converter.JdbcColumnDefaultValueConverter; +import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter; +import org.apache.gravitino.rel.expressions.Expression; + +/** Column default value converter for BigQuery. */ +public class BigQueryColumnDefaultValueConverter extends JdbcColumnDefaultValueConverter { + + @Override + public Expression toGravitino( + JdbcTypeConverter.JdbcTypeBean type, + String columnDefaultValue, + boolean isExpression, + boolean nullable) { + throw new NotImplementedException("To be implemented in the future"); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryExceptionConverter.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryExceptionConverter.java new file mode 100644 index 0000000000..f71b49672c --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryExceptionConverter.java @@ -0,0 +1,34 @@ +/* + * 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.bigquery.converter; + +import java.sql.SQLException; +import org.apache.gravitino.catalog.jdbc.converter.JdbcExceptionConverter; +import org.apache.gravitino.exceptions.GravitinoRuntimeException; + +/** Exception converter for BigQuery. */ +public class BigQueryExceptionConverter extends JdbcExceptionConverter { + + @Override + public GravitinoRuntimeException toGravitinoException(SQLException se) { + // For Phase 1, delegate to parent class implementation + // BigQuery-specific exception handling can be added in later phases + return super.toGravitinoException(se); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryTypeConverter.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryTypeConverter.java new file mode 100644 index 0000000000..b6b930c207 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/converter/BigQueryTypeConverter.java @@ -0,0 +1,37 @@ +/* + * 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.bigquery.converter; + +import org.apache.commons.lang3.NotImplementedException; +import org.apache.gravitino.catalog.jdbc.converter.JdbcTypeConverter; +import org.apache.gravitino.rel.types.Type; + +/** Type converter for BigQuery. */ +public class BigQueryTypeConverter extends JdbcTypeConverter { + + @Override + public Type toGravitino(JdbcTypeBean typeBean) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + public String fromGravitino(Type type) { + throw new NotImplementedException("To be implemented in the future"); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryDatabaseOperations.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryDatabaseOperations.java new file mode 100644 index 0000000000..96464acdcf --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryDatabaseOperations.java @@ -0,0 +1,57 @@ +/* + * 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.bigquery.operation; + +import com.google.common.collect.ImmutableSet; +import java.util.Map; +import java.util.Set; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.gravitino.catalog.jdbc.JdbcSchema; +import org.apache.gravitino.catalog.jdbc.operation.JdbcDatabaseOperations; +import org.apache.gravitino.exceptions.NoSuchSchemaException; + +/** Database operations for BigQuery. In BigQuery, databases are called datasets. */ +public class BigQueryDatabaseOperations extends JdbcDatabaseOperations { + + @Override + public String generateCreateDatabaseSql( + String databaseName, String comment, Map<String, String> properties) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + public String generateDropDatabaseSql(String databaseName, boolean cascade) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + public JdbcSchema load(String databaseName) throws NoSuchSchemaException { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected boolean supportSchemaComment() { + return true; + } + + @Override + protected Set<String> createSysDatabaseNameSet() { + return ImmutableSet.of("information_schema", "INFORMATION_SCHEMA"); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryTableOperations.java b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryTableOperations.java new file mode 100644 index 0000000000..f8119c57b2 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/java/org/apache/gravitino/catalog/bigquery/operation/BigQueryTableOperations.java @@ -0,0 +1,101 @@ +/* + * 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.bigquery.operation; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.gravitino.catalog.jdbc.JdbcColumn; +import org.apache.gravitino.catalog.jdbc.JdbcTable; +import org.apache.gravitino.catalog.jdbc.operation.JdbcTableOperations; +import org.apache.gravitino.rel.TableChange; +import org.apache.gravitino.rel.expressions.distributions.Distribution; +import org.apache.gravitino.rel.expressions.transforms.Transform; +import org.apache.gravitino.rel.indexes.Index; + +/** Table operations for BigQuery. */ +public class BigQueryTableOperations extends JdbcTableOperations { + + @Override + protected String generateCreateTableSql( + String tableName, + JdbcColumn[] columns, + String comment, + Map<String, String> properties, + Transform[] partitioning, + Distribution distribution, + Index[] indexes) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected boolean getAutoIncrementInfo(ResultSet resultSet) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected Map<String, String> getTableProperties(Connection connection, String tableName) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected List<Index> getIndexes(Connection connection, String databaseName, String tableName) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected Transform[] getTablePartitioning( + Connection connection, String databaseName, String tableName) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected void correctJdbcTableFields( + Connection connection, + String databaseName, + String tableName, + JdbcTable.Builder tableBuilder) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected String generateRenameTableSql(String oldTableName, String newTableName) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected String generatePurgeTableSql(String tableName) { + throw new UnsupportedOperationException( + "BigQuery does not support purge table in Gravitino, please use drop table"); + } + + @Override + protected String generateAlterTableSql( + String databaseName, String tableName, TableChange... changes) { + throw new NotImplementedException("To be implemented in the future"); + } + + @Override + protected Distribution getDistributionInfo( + Connection connection, String databaseName, String tableName) { + throw new NotImplementedException("To be implemented in the future"); + } +} diff --git a/catalogs/catalog-jdbc-bigquery/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvider b/catalogs/catalog-jdbc-bigquery/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvider new file mode 100644 index 0000000000..ac14e7c089 --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/resources/META-INF/services/org.apache.gravitino.CatalogProvider @@ -0,0 +1,19 @@ +# +# 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. +# +org.apache.gravitino.catalog.bigquery.BigQueryCatalog \ No newline at end of file diff --git a/catalogs/catalog-jdbc-bigquery/src/main/resources/jdbc-bigquery.conf b/catalogs/catalog-jdbc-bigquery/src/main/resources/jdbc-bigquery.conf new file mode 100644 index 0000000000..cf1befc96f --- /dev/null +++ b/catalogs/catalog-jdbc-bigquery/src/main/resources/jdbc-bigquery.conf @@ -0,0 +1,29 @@ +# +# 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. +# + +# BigQuery JDBC connection configuration +# Example configuration with Service Account authentication: +# 1. jdbc-driver = com.simba.googlebigquery.jdbc42.Driver +# 2. jdbc-url = jdbc:bigquery://https://www.googleapis.com/bigquery/v2:443 +# Google Cloud Project +# 3. project-id = <your-project-id> +# Note: jdbc-user and jdbc-password are not typically used with BigQuery +# 4. jdbc-user = <your-service-account>@<your-project-id>.iam.gserviceaccount.com +#/path/to/key.json +# 5. jdbc-password = <your-key-json-path> \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index d3f622dbab..3d11606aad 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -36,6 +36,7 @@ include("catalogs:catalog-lakehouse-hudi") include("catalogs:catalog-lakehouse-generic") include( "catalogs:catalog-jdbc-common", + "catalogs:catalog-jdbc-bigquery", "catalogs:catalog-jdbc-doris", "catalogs:catalog-jdbc-mysql", "catalogs:catalog-jdbc-postgresql",
