-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
### What changes were proposed in this pull request? - Support Schema operation for flink-connector. ### Why are the changes needed? - Fix: #3370 ### Does this PR introduce _any_ user-facing change? - no ### How was this patch tested? - add UTs and ITs
- Loading branch information
Showing
9 changed files
with
425 additions
and
27 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
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
38 changes: 38 additions & 0 deletions
38
...ector/src/test/java/com/datastrato/gravitino/flink/connector/catalog/TestBaseCatalog.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,38 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
package com.datastrato.gravitino.flink.connector.catalog; | ||
|
||
import com.datastrato.gravitino.SchemaChange; | ||
import com.google.common.collect.ImmutableMap; | ||
import java.util.Map; | ||
import org.apache.flink.table.catalog.CatalogDatabase; | ||
import org.apache.flink.table.catalog.CatalogDatabaseImpl; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class TestBaseCatalog { | ||
|
||
@Test | ||
public void testHiveSchemaChanges() { | ||
Map<String, String> currentProperties = ImmutableMap.of("key", "value", "key2", "value2"); | ||
CatalogDatabase current = new CatalogDatabaseImpl(currentProperties, null); | ||
|
||
Map<String, String> newProperties = ImmutableMap.of("key2", "new-value2", "key3", "value3"); | ||
CatalogDatabase updated = new CatalogDatabaseImpl(newProperties, null); | ||
|
||
SchemaChange[] schemaChange = BaseCatalog.getSchemaChange(current, updated); | ||
Assertions.assertEquals(3, schemaChange.length); | ||
Assertions.assertInstanceOf(SchemaChange.RemoveProperty.class, schemaChange[0]); | ||
Assertions.assertEquals("key", ((SchemaChange.RemoveProperty) schemaChange[0]).getProperty()); | ||
|
||
Assertions.assertInstanceOf(SchemaChange.SetProperty.class, schemaChange[1]); | ||
Assertions.assertEquals("key3", ((SchemaChange.SetProperty) schemaChange[1]).getProperty()); | ||
Assertions.assertEquals("value3", ((SchemaChange.SetProperty) schemaChange[1]).getValue()); | ||
|
||
Assertions.assertInstanceOf(SchemaChange.SetProperty.class, schemaChange[2]); | ||
Assertions.assertEquals("key2", ((SchemaChange.SetProperty) schemaChange[2]).getProperty()); | ||
Assertions.assertEquals("new-value2", ((SchemaChange.SetProperty) schemaChange[2]).getValue()); | ||
} | ||
} |
Oops, something went wrong.