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 error output column to show Flint index statement #436

Conversation

dai-chen
Copy link
Collaborator

@dai-chen dai-chen commented Jul 18, 2024

Description

This PR introduces a new output column, error, to display detailed root error messages when a Flint index is in a Failed state. The error column will only be included if the EXTENDED keyword is present in the SHOW FLINT INDEX statement, similar to the Spark SHOW TABLE EXTENDED statement.

The rationale behind this change is twofold:

  1. The error message is only relevant when the index status is "Failed"; for others, the error field will be empty.
  2. The error message can be lengthy, as it's collected from each Spark executor and currently truncated to 1000 characters, so they are returned only when needed.

Documentation

Updated user manual: https://github.com/dai-chen/opensearch-spark/blob/return-error-in-show-flint-index-statement/docs/index.md#all-indexes

Changes

  1. Added a separate grammar rule to accommodate potential future differences in the extended statement. Ref: https://github.com/apache/spark/blob/branch-3.3/sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBaseParser.g4#L168
  2. Refactored the AST builder to eliminate duplicate code and improve maintainability.

Example

Tested with EMR-S:

"result": [
  "{
    'flint_index_name':'flint_glue_default_http_logs_skipping_index',
    'kind':'skipping',
    'database':'default',
    'table':'http_logs',
    'auto_refresh':false,
    'status':'unavailable'
  }",
  """{
    'flint_index_name':'flint_glue_default_http_logs_streaming_error_index',
    'kind':'covering',
    'database':'default',
    'table':'http_logs',
    'index_name':'streaming_error',
    'auto_refresh':true,
    'status':'failed',
    'error':'failure in bulk execution:\n
    [0]: index [flint_glue_default_http_logs_streaming_error_index], id [kqSSvJAB69S8YQePXjzu], message [OpenSearchException[OpenSearch exception [type=cluster_block_exception, reason=index [flint_glue_default_http_logs_streaming_error_index] blocked by: [FORBIDDEN/8/index write (api)];]]]\n
    [1]: index [flint_glue_default_http_logs_streaming_error_index], id [k6SSvJAB69S8YQePXjzu], message [OpenSearchException[OpenSearch exception [type=cluster_block_exception, reason=index [flint_glue_default_http_logs_streaming_error_index] blocked by: [FORBIDDEN/8/index write (api)];]]]\n
    [2]: index [flint_glue_default_http_logs_streaming_error_index], id [lKSSvJAB69S8YQePXjzu], message [OpenSearchException[OpenSearch exception [type=cluster_block_exception, reason=index [flint_glue_default_http_logs_streaming_error_index] blocked by: [FORBIDDEN/8/index write (api)];]]]\n
    [3]: index [flint_glue_default_http_logs_streaming_error_index], id [laSSvJAB69S8YQePXjzu], messag...'
  }"""
],
"schema": [
  "{'column_name':'flint_index_name','data_type':'string'}",
  "{'column_name':'kind','data_type':'string'}",
  "{'column_name':'database','data_type':'string'}",
  "{'column_name':'table','data_type':'string'}",
  "{'column_name':'index_name','data_type':'string'}",
  "{'column_name':'auto_refresh','data_type':'boolean'}",
  "{'column_name':'status','data_type':'string'}",
  "{'column_name':'error','data_type':'string'}"
],
...

Issues Resolved

#405

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.

@dai-chen dai-chen added enhancement New feature or request 0.5 labels Jul 18, 2024
@dai-chen dai-chen self-assigned this Jul 18, 2024
@dai-chen dai-chen force-pushed the return-error-in-show-flint-index-statement branch from aa0a0e9 to b4cfb52 Compare July 22, 2024 17:57
@dai-chen dai-chen marked this pull request as ready for review July 22, 2024 21:37
@dai-chen dai-chen force-pushed the return-error-in-show-flint-index-statement branch from 8bfcf5c to 2d8d0a1 Compare July 24, 2024 21:35
@dai-chen dai-chen force-pushed the return-error-in-show-flint-index-statement branch from 2d8d0a1 to cdd92e4 Compare July 26, 2024 16:58
@dai-chen dai-chen merged commit 3e4df0a into opensearch-project:main Jul 26, 2024
4 checks passed
@dai-chen dai-chen deleted the return-error-in-show-flint-index-statement branch July 26, 2024 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.5 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants