mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
[improvement][headless]Simplify query sql and fix demo.
This commit is contained in:
@@ -65,7 +65,7 @@ public class SqlQueryParser implements QueryParser {
|
||||
// check if there are fields not matched with any metric or dimension
|
||||
if (allFields.size() > metricSchemas.size() + dimensions.size()) {
|
||||
queryStatement
|
||||
.setErrMsg("There are fields in the SQL not matched with any semantic column.");
|
||||
.setErrMsg("There are querying columns in the SQL not matched with any semantic field.");
|
||||
queryStatement.setStatus(1);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ public class DimensionNode extends SemanticNode {
|
||||
public static SqlNode build(Dimension dimension, SqlValidatorScope scope, EngineType engineType)
|
||||
throws Exception {
|
||||
SqlNode sqlNode = parse(dimension.getExpr(), scope, engineType);
|
||||
return buildAs(dimension.getName(), sqlNode);
|
||||
if (!dimension.getName().equals(dimension.getExpr())) {
|
||||
sqlNode = buildAs(dimension.getName(), sqlNode);
|
||||
}
|
||||
return sqlNode;
|
||||
}
|
||||
|
||||
public static List<SqlNode> expand(Dimension dimension, SqlValidatorScope scope,
|
||||
|
||||
@@ -9,7 +9,11 @@ public class MeasureNode extends SemanticNode {
|
||||
|
||||
public static SqlNode buildNonAgg(String alias, Measure measure, SqlValidatorScope scope,
|
||||
EngineType engineType) throws Exception {
|
||||
return buildAs(measure.getName(), getExpr(measure, alias, scope, engineType));
|
||||
if (measure.getExpr() == null) {
|
||||
return getExpr(measure, alias, scope, engineType);
|
||||
} else {
|
||||
return buildAs(measure.getName(), getExpr(measure, alias, scope, engineType));
|
||||
}
|
||||
}
|
||||
|
||||
public static SqlNode buildAgg(Measure measure, boolean noAgg, SqlValidatorScope scope,
|
||||
|
||||
@@ -317,12 +317,12 @@ public class SqlGenerateUtils {
|
||||
|
||||
public String getExpr(Measure measure, AggOption aggOption) {
|
||||
if (AggOperatorEnum.COUNT_DISTINCT.getOperator().equalsIgnoreCase(measure.getAgg())) {
|
||||
return AggOption.NATIVE.equals(aggOption) ? measure.getBizName()
|
||||
return AggOption.NATIVE.equals(aggOption) ? measure.getExpr()
|
||||
: AggOperatorEnum.COUNT.getOperator() + " ( " + AggOperatorEnum.DISTINCT + " "
|
||||
+ measure.getBizName() + " ) ";
|
||||
+ measure.getExpr() + " ) ";
|
||||
}
|
||||
return AggOption.NATIVE.equals(aggOption) ? measure.getBizName()
|
||||
: measure.getAgg() + " ( " + measure.getBizName() + " ) ";
|
||||
return AggOption.NATIVE.equals(aggOption) ? measure.getExpr()
|
||||
: measure.getAgg() + " ( " + measure.getExpr() + " ) ";
|
||||
}
|
||||
|
||||
public String getExpr(MetricResp metricResp) {
|
||||
|
||||
Reference in New Issue
Block a user