[fix][chat&headless]Adapt to new master.

This commit is contained in:
jerryjzhang
2024-12-29 10:45:18 +08:00
parent 7145f27671
commit 739514ddfa
2 changed files with 9 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
package com.tencent.supersonic.headless.core.pojo; package com.tencent.supersonic.headless.core.pojo;
import com.tencent.supersonic.common.pojo.enums.EngineType;
import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp; import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp;
import com.tencent.supersonic.headless.api.pojo.response.DimSchemaResp; import com.tencent.supersonic.headless.api.pojo.response.DimSchemaResp;
import com.tencent.supersonic.headless.api.pojo.response.MetricSchemaResp; import com.tencent.supersonic.headless.api.pojo.response.MetricSchemaResp;
@@ -31,4 +32,11 @@ public class Ontology {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
public EngineType getDatabaseType() {
if (Objects.nonNull(database)) {
return EngineType.fromString(database.getType().toUpperCase());
}
return null;
}
} }

View File

@@ -75,8 +75,7 @@ public class DefaultSemanticTranslator implements SemanticTranslator {
tables.add(Pair.of(ontologyInnerTable, ontologyInnerSql)); tables.add(Pair.of(ontologyInnerTable, ontologyInnerSql));
String finalSql = null; String finalSql = null;
if (sqlQuery.isSupportWith()) { if (sqlQuery.isSupportWith()) {
EngineType engineType = EngineType engineType = queryStatement.getOntology().getDatabaseType();
EngineType.fromString(queryStatement.getOntology().getDatabase().getType());
if (!SqlMergeWithUtils.hasWith(engineType, ontologyQuerySql)) { if (!SqlMergeWithUtils.hasWith(engineType, ontologyQuerySql)) {
finalSql = "with " + tables.stream() finalSql = "with " + tables.stream()
.map(t -> String.format("%s as (%s)", t.getLeft(), t.getRight())) .map(t -> String.format("%s as (%s)", t.getLeft(), t.getRight()))