-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[590] Add Iceberg HMS Catalog Sync implementation
- Loading branch information
1 parent
6e09f5d
commit c443f16
Showing
22 changed files
with
2,265 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
23 changes: 23 additions & 0 deletions
23
xtable-api/src/main/java/org/apache/xtable/model/storage/CatalogType.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 @@ | ||
/* | ||
* 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.xtable.model.storage; | ||
|
||
public class CatalogType { | ||
public static final String HMS = "HMS"; | ||
} |
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
33 changes: 33 additions & 0 deletions
33
xtable-core/src/main/java/org/apache/xtable/catalog/CatalogTableBuilder.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.xtable.catalog; | ||
|
||
import org.apache.xtable.model.InternalTable; | ||
import org.apache.xtable.model.catalog.CatalogTableIdentifier; | ||
|
||
/** | ||
* The interface for creating/updating catalog table object, each catalog can have its own | ||
* implementation that can be plugged in. | ||
*/ | ||
public interface CatalogTableBuilder<TABLE> { | ||
public TABLE getCreateTableRequest(InternalTable table, CatalogTableIdentifier tableIdentifier); | ||
|
||
public TABLE getUpdateTableRequest( | ||
InternalTable table, TABLE catalogTable, CatalogTableIdentifier tableIdentifier); | ||
} |
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
57 changes: 57 additions & 0 deletions
57
xtable-core/src/main/java/org/apache/xtable/catalog/TableFormatUtils.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,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.xtable.catalog; | ||
|
||
import java.util.Map; | ||
|
||
import org.apache.iceberg.TableProperties; | ||
|
||
import org.apache.xtable.exception.NotSupportedException; | ||
import org.apache.xtable.model.storage.TableFormat; | ||
|
||
public class TableFormatUtils { | ||
|
||
public static String getTableDataLocation( | ||
String tableFormat, String tableLocation, Map<String, String> properties) { | ||
switch (tableFormat) { | ||
case TableFormat.ICEBERG: | ||
return getIcebergDataLocation(tableLocation, properties); | ||
case TableFormat.HUDI: | ||
return tableLocation; | ||
default: | ||
throw new NotSupportedException("Unsupported table format: " + tableFormat); | ||
} | ||
} | ||
|
||
/** Get iceberg table data files location */ | ||
private static String getIcebergDataLocation( | ||
String tableLocation, Map<String, String> properties) { | ||
String dataLocation = properties.get(TableProperties.WRITE_DATA_LOCATION); | ||
if (dataLocation == null) { | ||
dataLocation = properties.get(TableProperties.WRITE_FOLDER_STORAGE_LOCATION); | ||
if (dataLocation == null) { | ||
dataLocation = properties.get(TableProperties.OBJECT_STORE_PATH); | ||
if (dataLocation == null) { | ||
dataLocation = String.format("%s/data", tableLocation); | ||
} | ||
} | ||
} | ||
return dataLocation; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
xtable-core/src/main/java/org/apache/xtable/catalog/hms/HMSCatalogConfig.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.xtable.catalog.hms; | ||
|
||
import java.util.Map; | ||
|
||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
@Getter | ||
@EqualsAndHashCode | ||
@ToString | ||
public class HMSCatalogConfig { | ||
|
||
private static final ObjectMapper OBJECT_MAPPER = | ||
new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | ||
|
||
@JsonProperty("externalCatalog.hms.serverUrl") | ||
private String serverUrl; | ||
|
||
protected static HMSCatalogConfig of(Map<String, String> properties) { | ||
try { | ||
return OBJECT_MAPPER.readValue( | ||
OBJECT_MAPPER.writeValueAsString(properties), HMSCatalogConfig.class); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
Oops, something went wrong.