-
Notifications
You must be signed in to change notification settings - Fork 145
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
Make explain of ProjectOperator with alias show both name and alias info #2911
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,4 +271,20 @@ public void testContentTypeOfExplainRequestShouldBeJson() throws IOException { | |
|
||
assertEquals("application/json; charset=UTF-8", response.getHeader("content-type")); | ||
} | ||
|
||
@Test | ||
public void explainAlias() throws IOException { | ||
|
||
String expectedOutputFilePath = | ||
TestUtils.getResourceFilePath("src/test/resources/expectedOutput/alias_explain.json"); | ||
String expectedOutput = | ||
Files.toString(new File(expectedOutputFilePath), StandardCharsets.UTF_8) | ||
.replaceAll("\r", ""); | ||
|
||
String result = | ||
explainQuery( | ||
String.format("SELECT (age + 1) AS agePlusOne FROM %s LIMIT 10", TEST_INDEX_ACCOUNT)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you overwrite some more complex cases:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For 2 and 3, could you create two issues for that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, but I think they may be the same cause. It's because we only use ProjectOperator instead of EvalOperator for SQL, while project don't support update and evaluate nested fields like eval. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Create a new issue to bring out this problem here: #2933 |
||
Assert.assertThat( | ||
result.replaceAll("\\s+", ""), equalTo(expectedOutput.replaceAll("\\s+", ""))); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"root": { | ||
"name": "ProjectOperator", | ||
"description": { | ||
"fields": "[(age+1) AS agePlusOne]" | ||
}, | ||
"children": [ | ||
{ | ||
"name": "OpenSearchIndexScan", | ||
"description": { | ||
"request": "OpenSearchQueryRequest(indexName=opensearch-sql_test_index_account,sourceBuilder={\"from\":0,\"size\":10,\"timeout\":\"1m\",\"_source\":{\"includes\":[\"age\"],\"excludes\":[]}},searchDone=false)" | ||
}, | ||
"children": [] | ||
} | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you should add a new method
getNameWithAlias()
in this class similar togetNameOrAlias()
.And I have some concerns when to use
getNameOrAlias()
and when to usegetNameWithAlias()
?Could you deep dive in it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getNameOrAlias
are used to get the field name to use in other operator. While in itstoString
, I just want to add more info than the field name, and it won't break the usage since it's just for explanation, no execution affection.I think we don't need to add such a new function as it will only be used in this
toString
method if added, we should add it unless it can be reused in other places as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt are there any other places to replace to
getNameWithAlias
either astoString
does. Can you help to confirm them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having scanned over all the usage of
getNameOrAlias
, I don't see any other places need to be replaced. They are all related to execution.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @qianheng-aws . @dai-chen Can u help to double confirm it since u are the author of this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I can't recall the specific details. I think it should be safe to change the
toString
method only.