Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Flint client and index management API #1634

Conversation

dai-chen
Copy link
Collaborator

@dai-chen dai-chen commented May 16, 2023

Description

  1. Add FlintClient interface with basic Flint index management API
  2. Add OpenSearch implementation for the client
  3. Copy and remove Spark dependency in OpenSearchSuite (will discuss with @penghuo if we want to move all IT stuff from flint-spark-integration to integ-test module)

Please see detailed design in opensearch-project/opensearch-spark#2 and read on below for more details. Later I will convert everything into individual doc in future PR.

Flint Specification

Note that Flint spec is subject to change during development and thus FlintMetadata stores everything in Map. Will change this to strong type once finalized.

Flint metadata sample:

{
  "version": "0.1",
  "indexConfig": {
    "kind": "SkippingIndex",
    "properties": {
      "indexedColumns": ...
     }
  },
  "source": "alb_logs",
  "state": "active",
  "enabled": true
}

Flint Java SDK

API:

  • createIndex
  • exists
  • getIndexMetadata

Usage (more details in FlintOpenSearchClientSuite):

// Initialized Flint client for a specific storage
FlintClient flintClient = new FlintOpenSearchClient("localhost", 9200);

Map<String, String> schema =
  Map.of(
    "file_path", "keyword",
    "elb_status_code": "integer");
Map<String, Object> meta =
  Map.of(
    "version": "0.1",
    "indexConfig": Map.of(...));

FlintMetadata metadata = new FlintMetadata(schema, meta)
flintClient.createIndex("alb_logs_skipping_index", metadata)

Flint OpenSearch Storage

OpenSearch index mapping sample:

alb_logs_skipping_index
{
  "_meta": {
    "version": "0.1",
    "indexConfig": {
        "kind": "SkippingIndex",
        "properties": {
          "indexedColumns": [
            "elb_status_code": "value_list"
          ]
        }
    }
    ......
  },
  "properties": {
     "file_path": {
       "type": "keyword"
     },
     "elb_status_code": {
         "type": "integer"
     }
   }
}

Testing

Followed developer guide: https://github.com/opensearch-project/sql/blob/feature/flint/flint/DEVELOPER_GUIDE.md

$ sbt scalafmtAll

$ sbt integtest/test 
...
[info] FlintOpenSearchClientSuite:
[info] Flint OpenSearch client
[info] - should create index successfully
[info] - should return false if index not exist

Issues Resolved

#1635

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@codecov
Copy link

codecov bot commented May 16, 2023

Codecov Report

Merging #1634 (9d3c2fd) into feature/flint (b19db71) will not change coverage.
The diff coverage is n/a.

❗ Current head 9d3c2fd differs from pull request most recent head 66f49a7. Consider uploading reports for the commit 66f49a7 to get more accurate results

@@               Coverage Diff                @@
##             feature/flint    opensearch-project/sql#1634   +/-   ##
================================================
  Coverage            97.19%   97.19%           
  Complexity            4107     4107           
================================================
  Files                  371      371           
  Lines                10464    10464           
  Branches               706      706           
================================================
  Hits                 10170    10170           
  Misses                 287      287           
  Partials                 7        7           
Flag Coverage Δ
sql-engine 97.19% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@dai-chen dai-chen added the enhancement New feature or request label May 17, 2023
@dai-chen dai-chen marked this pull request as ready for review May 17, 2023 00:12
@dai-chen dai-chen requested a review from penghuo May 17, 2023 00:15
Signed-off-by: Chen Dai <[email protected]>
@dai-chen dai-chen merged commit 84ccf88 into opensearch-project:feature/flint May 17, 2023
@dai-chen dai-chen deleted the add-flint-client-index-management-api branch May 17, 2023 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Flint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants