[improvement][headless]Simplify query sql and fix demo.
Some checks failed
supersonic CentOS CI / build (21) (push) Has been cancelled
supersonic mac CI / build (21) (push) Has been cancelled
supersonic ubuntu CI / build (21) (push) Has been cancelled
supersonic windows CI / build (21) (push) Has been cancelled

This commit is contained in:
jerryjzhang
2024-12-31 09:13:56 +08:00
parent a2f54d4c80
commit a46e89af56
7 changed files with 29 additions and 26 deletions

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -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) {