mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-13 21:17:08 +00:00
(improvement)(project) The Corrector is integrated into the Semantic module as an intermediate step for translating S2QL into SQL (#306)
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.api.model.response;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author: kanedai
|
||||
* @date: 2023/3/29
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class ItemDateResp {
|
||||
|
||||
private String dateFormat;
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
private String datePeriod;
|
||||
private List<String> unavailableDateList = new ArrayList<>();
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.api.query.enums;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum FilterOperatorEnum {
|
||||
IN("IN"),
|
||||
NOT_IN("NOT_IN"),
|
||||
EQUALS("="),
|
||||
BETWEEN("BETWEEN"),
|
||||
GREATER_THAN(">"),
|
||||
GREATER_THAN_EQUALS(">="),
|
||||
IS_NULL("IS_NULL"),
|
||||
IS_NOT_NULL("IS_NOT_NULL"),
|
||||
LIKE("LIKE"),
|
||||
MINOR_THAN("<"),
|
||||
MINOR_THAN_EQUALS("<="),
|
||||
NOT_EQUALS("!="),
|
||||
SQL_PART("SQL_PART"),
|
||||
EXISTS("EXISTS");
|
||||
|
||||
private String value;
|
||||
|
||||
FilterOperatorEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static FilterOperatorEnum getSqlOperator(String type) {
|
||||
for (FilterOperatorEnum operatorEnum : FilterOperatorEnum.values()) {
|
||||
if (operatorEnum.value.equalsIgnoreCase(type) || operatorEnum.name().equalsIgnoreCase(type)) {
|
||||
return operatorEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.api.query.pojo;
|
||||
|
||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Criterion {
|
||||
|
||||
private String column;
|
||||
|
||||
private FilterOperatorEnum operator;
|
||||
|
||||
private Object value;
|
||||
|
||||
private List<Object> values;
|
||||
|
||||
private String dataType;
|
||||
|
||||
public Criterion(String column, FilterOperatorEnum operator, Object value, String dataType) {
|
||||
super();
|
||||
this.column = column;
|
||||
this.operator = operator;
|
||||
this.value = value;
|
||||
this.dataType = dataType;
|
||||
|
||||
if (FilterOperatorEnum.BETWEEN.name().equals(operator) || FilterOperatorEnum.IN.name().equals(operator)
|
||||
|| FilterOperatorEnum.NOT_IN.name().equals(operator)) {
|
||||
this.values = (List) value;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isNeedApostrophe() {
|
||||
return Arrays.stream(StringDataType.values())
|
||||
.filter(value -> this.dataType.equalsIgnoreCase(value.getType())).findFirst()
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
|
||||
public enum NumericDataType {
|
||||
TINYINT("TINYINT"),
|
||||
SMALLINT("SMALLINT"),
|
||||
MEDIUMINT("MEDIUMINT"),
|
||||
INT("INT"),
|
||||
INTEGER("INTEGER"),
|
||||
BIGINT("BIGINT"),
|
||||
FLOAT("FLOAT"),
|
||||
DOUBLE("DOUBLE"),
|
||||
DECIMAL("DECIMAL"),
|
||||
NUMERIC("NUMERIC"),
|
||||
;
|
||||
private String type;
|
||||
|
||||
NumericDataType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public enum StringDataType {
|
||||
VARCHAR("VARCHAR"),
|
||||
STRING("STRING"),
|
||||
;
|
||||
private String type;
|
||||
|
||||
StringDataType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.tencent.supersonic.semantic.api.query.pojo;
|
||||
|
||||
import com.tencent.supersonic.semantic.api.query.enums.FilterOperatorEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Filter {
|
||||
|
||||
private Relation relation = Relation.FILTER;
|
||||
private String bizName;
|
||||
private String name;
|
||||
private FilterOperatorEnum operator;
|
||||
private Object value;
|
||||
private List<Filter> children;
|
||||
|
||||
public Filter(String bizName, FilterOperatorEnum operator, Object value) {
|
||||
this.bizName = bizName;
|
||||
this.operator = operator;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Filter(Relation relation, String bizName, FilterOperatorEnum operator, Object value) {
|
||||
this.relation = relation;
|
||||
this.bizName = bizName;
|
||||
this.operator = operator;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
sb.append("\"relation\":")
|
||||
.append(relation);
|
||||
sb.append(",\"bizName\":\"")
|
||||
.append(bizName).append('\"');
|
||||
sb.append(",\"name\":\"")
|
||||
.append(name).append('\"');
|
||||
sb.append(",\"operator\":")
|
||||
.append(operator);
|
||||
sb.append(",\"value\":")
|
||||
.append(value);
|
||||
sb.append(",\"children\":")
|
||||
.append(children);
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public enum Relation {
|
||||
FILTER, OR, AND
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package com.tencent.supersonic.semantic.api.query.request;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Cache;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Filter;
|
||||
import com.tencent.supersonic.common.pojo.Filter;
|
||||
import com.tencent.supersonic.semantic.api.query.pojo.Param;
|
||||
import com.tencent.supersonic.common.pojo.Aggregator;
|
||||
import com.tencent.supersonic.common.pojo.DateConf;
|
||||
|
||||
Reference in New Issue
Block a user