mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-14 22:25:19 +00:00
(improvement)(chat) support nested query sql (#210)
This commit is contained in:
@@ -139,8 +139,16 @@ public class SqlParserSelectHelper {
|
||||
}
|
||||
|
||||
public static List<String> getAllFields(String sql) {
|
||||
List<PlainSelect> plainSelects = getPlainSelects(getPlainSelect(sql));
|
||||
Set<String> results = new HashSet<>();
|
||||
for (PlainSelect plainSelect : plainSelects) {
|
||||
List<String> fields = getFieldsByPlainSelect(plainSelect);
|
||||
results.addAll(fields);
|
||||
}
|
||||
return new ArrayList<>(results);
|
||||
}
|
||||
|
||||
PlainSelect plainSelect = getPlainSelect(sql);
|
||||
private static ArrayList<String> getFieldsByPlainSelect(PlainSelect plainSelect) {
|
||||
if (Objects.isNull(plainSelect)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user