opensearch-project / sql

Query your data using familiar SQL or intuitive Piped Processing Language (PPL)
https://opensearch.org/docs/latest/search-plugins/sql/index/
Apache License 2.0
120 stars 139 forks source link

[BUG] Query parameter "pretty" doesn't work in RAW format #2718

Open LantaoJin opened 5 months ago

LantaoJin commented 5 months ago

What is the bug? When user queries with SQL in OpenSearch-Dashboard, OpenSearch-Dashboard adds pretty=true in query parameter by default. We can check it from logs:

[2024-06-06T11:12:39,965][INFO ][o.o.s.l.p.RestSqlAction ] [integTest-0] [6d22cbf7-9125-4940-9d9b-227f08ab9894] Incoming request /_plugins/_sql?pretty=true [2024-06-06T10:58:23,798][INFO ][o.o.s.l.p.RestSqlAction ] [integTest-0] [ee4fd81d-1af6-4298-ac28-e10009755472] Incoming request /_plugins/_sql?format=raw&pretty=true

But the parameter pretty doesn't work on the raw format.

How can one reproduce the bug? Steps to reproduce the behavior:

  1. Go to Dev_Tools in OpenSearch Playground: https://playground.opensearch.org/app/dev_tools#/console
  2. Query with raw format
    POST /_plugins/_sql?format=raw
    {
    "query" : """
    SELECT type, manufacturer, customer_last_name, day_of_week, total_quantity, currency, taxless_total_price FROM opensearch_dashboards_sample_data_ecommerce LIMIT 5
    """
    }
  3. See the response wasn't pretty formatted.
    type|manufacturer|customer_last_name|day_of_week|total_quantity|currency|taxless_total_price
    order|Elitelligence|Underwood|Monday|2|EUR|36.98
    order|Champion Arts|Bailey|Sunday|2|EUR|53.98
    order|Low Tide Media|Butler|Sunday|2|EUR|199.98
    order|Primemaster|Chandler|Sunday|2|EUR|174.98
    order|Elitelligence|Weber|Monday|2|EUR|80.98

What is the expected behavior? When the query parameter contains pretty=true, the response should be pretty formatted as follow

type |manufacturer   |customer_last_name|day_of_week|total_quantity|currency|taxless_total_price
order|Elitelligence  |Underwood         |Monday     |2             |EUR     |36.98
order|Champion Arts  |Bailey            |Sunday     |2             |EUR     |53.98
order|Low Tide Media |Butler            |Sunday     |2             |EUR     |199.98
order|Primemaster    |Chandler          |Sunday     |2             |EUR     |174.98
order|Elitelligence  |Weber             |Monday     |2             |EUR     |80.98

When the query parameter contains pretty=false or without pretty parameter, the response will be kept current output formatting.

What is your host/environment?

Do you have any screenshots? If applicable, add screenshots to help explain your problem.

Do you have any additional context? Add any other context about the problem.

dblock commented 4 months ago

[Catch All Triage - Attendees 1, 2, 3, 4, 5]

Thanks for reporting this issue.