-
Notifications
You must be signed in to change notification settings - Fork 141
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
Union query result should work in JDBC format #2757
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.sql.legacy.domain; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class Union extends Query { | ||
private final Select firstTable; | ||
private final Select secondTable; | ||
|
||
public Union(Select firstTable, Select secondTable) { | ||
this.firstTable = firstTable; | ||
this.secondTable = secondTable; | ||
this.firstTable.setPartOfUnion(true); | ||
this.secondTable.setPartOfUnion(true); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ private List<String> getFormatsForColumn(String columnName) { | |
private Set<String> getDateColumns(List<Schema.Column> columns) { | ||
return columns.stream() | ||
.filter(column -> column.getType().equals(Schema.Type.DATE.nameLowerCase())) | ||
.map(Schema.Column::getName) | ||
.map(Schema.Column::getIdentifier) | ||
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. Is this related to the current issue? 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. Good catching! This change should be reverted. What change we need for alias case is just this diff: https://github.com/opensearch-project/sql/pull/2757/files#diff-943465139286a5010c19cab380f141e3c9bc26fb02652bedbc6a7bbec5c98cc3R46 |
||
.collect(Collectors.toSet()); | ||
} | ||
|
||
|
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.
does UNION works for query with aggregation?
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.
Actually, UNION with Agg in legacy engine has bugs by my testing whatever format set. This fixing doesn't cover all existed bugs. You can try below queries.
May be we could open another ticket to fix the problems in Union with Agg? Or migrating to v2?
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.
And seems current implementation doesn't distinguish UNION and UNION ALL. A better way is to re-implement UNION in v2, PPL also requests multi-search implementation.
Again, this fixing is just for addressing the NPE problem of UNION query in JDBC format (such a common use case).