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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Query should return a response json with full data #1679

Closed
pandareen opened this issue Apr 29, 2022 · 2 comments
Closed

SQL Query should return a response json with full data #1679

pandareen opened this issue Apr 29, 2022 · 2 comments

Comments

@pandareen
Copy link

pandareen commented Apr 29, 2022

馃殌 Feature Proposal

Current sql query api in node.js is returning a resultset and we have to iterate over it and create final key:value json object. I propose it return a json with key:value pairs in result data. The SQL REST API already returns a json (Even though it doesn't return a key value pair).

Motivation

This is to stop us from running into memory issues when the result set is large and the for loop runs for too long.

Example

Existing code is this (picked from here)

  const result = await client.sql.query({
    query: "SELECT * FROM \"game-of-thrones\" WHERE house='stark'"
  })

  console.log(result)

  const data = result.rows.map(row => {
    const obj = {}
    for (let i = 0; i < row.length; i++) {
      obj[result.columns[i].name] = row[i]
    }
    return obj
  })

  console.log(data)

Proposed code is this instead of the user iterating on the resultset to make the final JSON, can we have the result.data as a JSON response, which is const data as per the above example.

@delvedor
Copy link
Member

delvedor commented May 6, 2022

Hello! The client returns the response as Elasticsearch crafts them, and it cannot change them.
You are asking more of a helper, which currently doesn't exist for SQL.
I'll mark this as a feature request and think about it.

Copy link
Contributor

github-actions bot commented Nov 3, 2023

This issue is stale because it has been open 90 days with no activity. Remove the stale label, or leave a comment, or this will be closed in 14 days.

@github-actions github-actions bot added the stale label Nov 3, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants