-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Managed Iceberg] support BQMS catalog (#33511)
* Add BQMS catalog * trigger integration tests * build fix * use shaded jar * shadowClosure * use global timeout for tests * define version in BeamModulePlugin * address comments
- Loading branch information
1 parent
4fc5c86
commit 6b3783f
Showing
8 changed files
with
166 additions
and
5 deletions.
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
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,63 @@ | ||
/* | ||
* 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. | ||
*/ | ||
plugins { | ||
id 'org.apache.beam.module' | ||
} | ||
|
||
applyJavaNature( | ||
automaticModuleName: 'org.apache.beam.sdk.io.iceberg.bqms', | ||
shadowClosure: {}, | ||
exportJavadoc: false, | ||
publish: false, // it's an intermediate jar for io-expansion-service | ||
validateShadowJar: false | ||
) | ||
|
||
def libDir = "$buildDir/libs" | ||
def bqmsFileName = "iceberg-bqms-catalog-${iceberg_bqms_catalog_version}.jar" | ||
task downloadBqmsJar(type: Copy) { | ||
// TODO: remove this workaround and downlooad normally when the catalog gets open-sourced: | ||
// (https://github.com/apache/iceberg/pull/11039) | ||
def jarUrl = "https://storage.googleapis.com/spark-lib/bigquery/iceberg-bigquery-catalog-${iceberg_bqms_catalog_version}.jar" | ||
def outputDir = file("$libDir") | ||
outputDir.mkdirs() | ||
def destFile = new File(outputDir, bqmsFileName) | ||
|
||
if (!destFile.exists()) { | ||
try { | ||
ant.get(src: jarUrl, dest: destFile) | ||
println "Successfully downloaded BQMS catalog jar: $destFile" | ||
} catch (Exception e) { | ||
println "Could not download $jarUrl: ${e.message}" | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
flatDir { | ||
dirs "$libDir" | ||
} | ||
} | ||
|
||
compileJava.dependsOn downloadBqmsJar | ||
|
||
dependencies { | ||
implementation files("$libDir/$bqmsFileName") | ||
} | ||
|
||
description = "Apache Beam :: SDKs :: Java :: IO :: Iceberg :: BigQuery Metastore" | ||
ext.summary = "A copy of the BQMS catalog." |
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
76 changes: 76 additions & 0 deletions
76
...berg/src/test/java/org/apache/beam/sdk/io/iceberg/catalog/BigQueryMetastoreCatalogIT.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,76 @@ | ||
/* | ||
* 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.beam.sdk.io.iceberg.catalog; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
import org.apache.beam.vendor.guava.v32_1_2_jre.com.google.common.collect.ImmutableMap; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.iceberg.CatalogUtil; | ||
import org.apache.iceberg.catalog.Catalog; | ||
import org.apache.iceberg.catalog.Namespace; | ||
import org.apache.iceberg.catalog.TableIdentifier; | ||
|
||
public class BigQueryMetastoreCatalogIT extends IcebergCatalogBaseIT { | ||
static final String BQMS_CATALOG = "org.apache.iceberg.gcp.bigquery.BigQueryMetastoreCatalog"; | ||
static final String DATASET = "managed_iceberg_bqms_tests_no_delete"; | ||
static final long SALT = System.nanoTime(); | ||
|
||
@Override | ||
public String tableId() { | ||
return DATASET + "." + testName.getMethodName() + "_" + SALT; | ||
} | ||
|
||
@Override | ||
public Catalog createCatalog() { | ||
return CatalogUtil.loadCatalog( | ||
BQMS_CATALOG, | ||
"bqms_" + catalogName, | ||
ImmutableMap.<String, String>builder() | ||
.put("gcp_project", options.getProject()) | ||
.put("gcp_location", "us-central1") | ||
.put("warehouse", warehouse) | ||
.build(), | ||
new Configuration()); | ||
} | ||
|
||
@Override | ||
public void catalogCleanup() throws IOException { | ||
for (TableIdentifier tableIdentifier : catalog.listTables(Namespace.of(DATASET))) { | ||
// only delete tables that were created in this test run | ||
if (tableIdentifier.name().contains(String.valueOf(SALT))) { | ||
catalog.dropTable(tableIdentifier); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Map<String, Object> managedIcebergConfig(String tableId) { | ||
return ImmutableMap.<String, Object>builder() | ||
.put("table", tableId) | ||
.put( | ||
"catalog_properties", | ||
ImmutableMap.<String, String>builder() | ||
.put("gcp_project", options.getProject()) | ||
.put("gcp_location", "us-central1") | ||
.put("warehouse", warehouse) | ||
.put("catalog-impl", BQMS_CATALOG) | ||
.build()) | ||
.build(); | ||
} | ||
} |
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