-
Notifications
You must be signed in to change notification settings - Fork 33
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
* fix missed renames * rename for log entry properties * correct typo planTransformer * add FlintIndexMetadataService * interface class for FlintIndexMetadataService * move FlintMetadata and FlintVersion to flint-commons * remove ser/de from FlintMetadata; move to OS impl for FlintIndexMetadataService * remove schema parser in FlintMetadata builder to remove dependency to opensearch * FlintSparkIndex generate not only schema json but also map * FlintMetadataSuite divided into two: one for builder and one for ser/de, which is merged to FlintOpenSearchIndexMetadataServiceSuite * move get metadata functions to new service * Remove getIndexMetadata and getAllIndexMetadata from FlintClient * Implement the two for OpenSearch * TODO: sanitize index name * Add builder for FlintIndexMetadataService and options * Refactor caller of FlintClient.get(All)IndexMetadata with FlintIndexMetadataService * TODO: test suite for getIndexMetadata and getAllIndexMetadata (might overlap with FlintOpenSearchClientSuite) * update index metadata * remove updateIndex from FlintClient * implement updateIndexMetadata for FlintOpenSearchIndexMetadataService * updateIndexMetadata upon create index in FlintSpark * for OS client + OS index metadata service, the call for update is redundant * it's for when some other index metadata service implementation is provided * TODO: Suite for updateIndexMetadata (now shared with FlintOpenSearchClientSuite) * empty implementation for OS deleteIndexMetadata * sanitize index name * fix new FlintOption missing from FlintSparkConf * fix FlintOpenSearchClientSuite * delete file (missed in resolving conflict) * Use service builder in OpenSearchCluster * fix service builder class * fix FlintOptions for custom class spark properties * remove SparkConf from builder argument * fix IT * add test suites * sanitize index name for opensearch metadata log * remove spark-warehouse files * exclude _meta field for createIndex in OpenSearch * catch client creation exception * Fetch metadata for OpenSearch table * OpenSearchCluster move to java file because scala object cannot be mocked in mockito * update doc with spark config --------- (cherry picked from commit f5ad574) Signed-off-by: Sean Kao <[email protected]>
- Loading branch information
1 parent
ab46239
commit f470ff5
Showing
41 changed files
with
815 additions
and
467 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
51 changes: 51 additions & 0 deletions
51
...ommons/src/main/scala/org/opensearch/flint/common/metadata/FlintIndexMetadataService.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 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.common.metadata; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Flint index metadata service provides API for index metadata related operations on a Flint index | ||
* regardless of underlying storage. | ||
* <p> | ||
* Custom implementations of this interface are expected to provide a public constructor with | ||
* the signature {@code public MyCustomService(SparkConf sparkConf)} to be instantiated by | ||
* the FlintIndexMetadataServiceBuilder. | ||
*/ | ||
public interface FlintIndexMetadataService { | ||
|
||
/** | ||
* Retrieve metadata for a Flint index. | ||
* | ||
* @param indexName index name | ||
* @return index metadata | ||
*/ | ||
FlintMetadata getIndexMetadata(String indexName); | ||
|
||
/** | ||
* Retrieve all metadata for Flint index whose name matches the given pattern. | ||
* | ||
* @param indexNamePattern index name pattern | ||
* @return map where the keys are the matched index names, and the values are | ||
* corresponding index metadata | ||
*/ | ||
Map<String, FlintMetadata> getAllIndexMetadata(String... indexNamePattern); | ||
|
||
/** | ||
* Update metadata for a Flint index. | ||
* | ||
* @param indexName index name | ||
* @param metadata index metadata to update | ||
*/ | ||
void updateIndexMetadata(String indexName, FlintMetadata metadata); | ||
|
||
/** | ||
* Delete metadata for a Flint index. | ||
* | ||
* @param indexName index name | ||
*/ | ||
void deleteIndexMetadata(String indexName); | ||
} |
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
32 changes: 32 additions & 0 deletions
32
flint-commons/src/test/scala/org/opensearch/flint/common/metadata/FlintMetadataSuite.scala
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,32 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.flint.common.metadata | ||
|
||
import scala.collection.JavaConverters.mapAsJavaMapConverter | ||
|
||
import org.opensearch.flint.common.FlintVersion.current | ||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers | ||
|
||
class FlintMetadataSuite extends AnyFlatSpec with Matchers { | ||
"builder" should "build FlintMetadata with provided fields" in { | ||
val builder = new FlintMetadata.Builder | ||
builder.name("test_index") | ||
builder.kind("test_kind") | ||
builder.source("test_source_table") | ||
builder.addIndexedColumn(Map[String, AnyRef]("test_field" -> "spark_type").asJava) | ||
builder.schema(Map[String, AnyRef]("test_field" -> Map("type" -> "os_type").asJava).asJava) | ||
|
||
val metadata = builder.build() | ||
|
||
metadata.version shouldBe current() | ||
metadata.name shouldBe "test_index" | ||
metadata.kind shouldBe "test_kind" | ||
metadata.source shouldBe "test_source_table" | ||
metadata.indexedColumns shouldBe Array(Map("test_field" -> "spark_type").asJava) | ||
metadata.schema shouldBe Map("test_field" -> Map("type" -> "os_type").asJava).asJava | ||
} | ||
} |
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
Oops, something went wrong.