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

[FEATURE] Preserve existing index mappings when updating metadata cache #931

Closed
seankao-az opened this issue Nov 19, 2024 · 0 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@seankao-az
Copy link
Collaborator

Is your feature request related to a problem?
As part of #746 , currently FlintOpenSearchMetadataCacheWriter overwrites the index mapping and does not preserve content written by custom implementation of FlintIndexMetadataService (set by spark property spark.datasource.flint.customFlintIndexMetadataServiceClass).
For example, if index already has mappings:

{
      "_meta": {
        "customField1": "customValue",
        "properties": {
          "customField2": "customValue2"
        }
      },
      "properties": {
        ...
      }
}

Then the cache writer would overwrite it to

{
      "_meta": {
        "properties": {
          "refreshInterval": 900,
          "sourceTables": [
            "datasource.database.table"
          ],
          "metadataCacheVersion": "1.0",
          "lastRefreshTime": 1234567890123
        }
      },
      "properties": {
        ...
      }
}

Removing both _meta.customField1 and _meta.properties.customField2.

The cached fields should be added upon the existing mappings, not replace them.
Desired outcome for above example:

{
      "_meta": {
        "customField1": "customValue1",
        "properties": {
          "customField2": "customValue2",
          "refreshInterval": 900,
          "sourceTables": [
            "datasource.database.table"
          ],
          "metadataCacheVersion": "1.0",
          "lastRefreshTime": 1234567890123
        }
      },
      "properties": {
        ...
      }
}

What solution would you like?
Since OpenSearch index mappings only support the PUT api to replace the whole mappings content, in FlintOpenSearchMetadataCacheWriter.updateMetadataCache, we need to

  1. GET current mappings content as json
  2. Add fields for metadata cache to the json
  3. PUT request for the combined json

What alternatives have you considered?
Alternative is to remove FlintOpenSearchMetadataCacheWriter, and instead, have FlintIndexMetadataService take care of the cache write themselves. This approach avoids overwriting as we only update mappings once for each command, instead of twice.

Do you have any additional context?
Add any other context or screenshots about the feature request here.

@seankao-az seankao-az added enhancement New feature or request untriaged labels Nov 19, 2024
@seankao-az seankao-az changed the title [FEATURE] [FEATURE] Preserve existing index mappings when updating metadata cache Nov 19, 2024
@seankao-az seankao-az self-assigned this Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants