Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Feature request: support select columns from right index in left join query #505

Open
seraphjiang opened this issue Jun 4, 2020 · 1 comment
Labels
enhancement New feature or request SQL

Comments

@seraphjiang
Copy link
Member

Use case

i have two index patterns
index1 [account, col1]
index2* [account, col2]

they share same key account.

when I run follow query, I'm not able to get columns from index2*.

GET _opendistro/_sql?format=csv
{
  "query": """
  SELECT *, i2.*
  FROM index1 i1 
  LEFT JOIN  [index2*] as i2
    ON i1.account.keyword = i2.account.keyword 
  LIMIT 1000
"""
}
# only columns from left index are selected
account, col1
...
...

version

1.4.0.0

@penghuo penghuo added the enhancement New feature or request label Jun 4, 2020
@penghuo
Copy link
Contributor

penghuo commented Jun 4, 2020

Test with sample data.

PUT /index1/_doc/1
{
  "account": "a-1",
  "region": "us-east-1"
}

PUT /index1/_doc/2
{
  "account": "b-1",
  "region": "us-east-1"
}

PUT /index21/_doc/1
{
  "account": "a-1",
  "size": "10"
}

PUT /index22/_doc/2
{
  "account": "a-1",
  "size": "15"
}

POST _opendistro/_sql?format=csv
{
  "query": """
  SELECT *, i2.*
  FROM index1 i1 
  LEFT JOIN  [index2*] as i2
    ON i1.account.keyword = i2.account.keyword 
  LIMIT 1000
"""
}

The result is

i1.account,i2.size,i1.region,i2.account
a-1,10,us-east-1,a-1
a-1,15,us-east-1,a-1
b-1,,us-east-1,

@seraphjiang, could you provide sample data for your failure cases?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request SQL
Projects
None yet
Development

No branches or pull requests

3 participants