[fix][headless]Fix a set of known issues.
Some checks are pending
supersonic CentOS CI / build (21) (push) Waiting to run
supersonic mac CI / build (21) (push) Waiting to run
supersonic ubuntu CI / build (21) (push) Waiting to run
supersonic windows CI / build (21) (push) Waiting to run

This commit is contained in:
jerryjzhang
2025-01-14 14:47:35 +08:00
parent 329756056c
commit 2b28aeea6f
10 changed files with 44 additions and 25 deletions

View File

@@ -96,7 +96,7 @@ public class ParseInfoFormatProcessor implements ParseResultProcessor {
// extract date filter from S2SQL // extract date filter from S2SQL
try { try {
if (parseInfo.getDateInfo() == null && !CollectionUtils.isEmpty(expressions)) { if (!CollectionUtils.isEmpty(expressions)) {
parseInfo.setDateInfo(extractDateFilter(expressions, dsSchema)); parseInfo.setDateInfo(extractDateFilter(expressions, dsSchema));
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -144,6 +144,15 @@ public class SqlSelectHelper {
return result; return result;
} }
public static Set<String> getAliasFields(String sql) {
List<PlainSelect> plainSelects = getPlainSelects(getPlainSelect(sql));
Set<String> aliasFields = new HashSet<>();
plainSelects.forEach(select -> {
aliasFields.addAll(getAliasFields(select));
});
return aliasFields;
}
public static List<PlainSelect> getPlainSelect(Select selectStatement) { public static List<PlainSelect> getPlainSelect(Select selectStatement) {
if (selectStatement == null) { if (selectStatement == null) {
return null; return null;

View File

@@ -59,9 +59,15 @@ public class DateConf {
return false; return false;
} }
DateConf dateConf = (DateConf) o; DateConf dateConf = (DateConf) o;
return dateMode == dateConf.dateMode && Objects.equals(startDate, dateConf.startDate) if (dateMode != dateConf.dateMode) {
&& Objects.equals(endDate, dateConf.endDate) && Objects.equals(unit, dateConf.unit) return false;
&& Objects.equals(period, dateConf.period); }
if (dateMode == DateMode.RECENT) {
return Objects.equals(unit, dateConf.unit) && Objects.equals(period, dateConf.period);
} else {
return Objects.equals(startDate, dateConf.startDate)
&& Objects.equals(endDate, dateConf.endDate);
}
} }
@Override @Override

View File

@@ -114,7 +114,7 @@ public class PromptHelper {
dimensionStr.append(dimension.getName()); dimensionStr.append(dimension.getName());
if (!CollectionUtils.isEmpty(dimension.getAlias())) { if (!CollectionUtils.isEmpty(dimension.getAlias())) {
StringBuilder alias = new StringBuilder(); StringBuilder alias = new StringBuilder();
dimension.getAlias().stream().forEach(a -> alias.append(a + ",")); dimension.getAlias().stream().forEach(a -> alias.append(a + ";"));
dimensionStr.append(" ALIAS '" + alias + "'"); dimensionStr.append(" ALIAS '" + alias + "'");
} }
if (StringUtils.isNotEmpty(dimension.getTimeFormat())) { if (StringUtils.isNotEmpty(dimension.getTimeFormat())) {

View File

@@ -45,7 +45,7 @@ public class JdbcExecutor implements QueryExecutor {
sqlUtil.queryInternal(queryStatement.getSql(), queryResultWithColumns); sqlUtil.queryInternal(queryStatement.getSql(), queryResultWithColumns);
queryResultWithColumns.setSql(sql); queryResultWithColumns.setSql(sql);
} catch (Exception e) { } catch (Exception e) {
log.error("queryInternal error [{}]", StringUtils.normalizeSpace(e.toString())); log.error("queryInternal with error [{}]", StringUtils.normalizeSpace(e.getMessage()));
queryResultWithColumns.setErrorMsg(e.getMessage()); queryResultWithColumns.setErrorMsg(e.getMessage());
} }
return queryResultWithColumns; return queryResultWithColumns;

View File

@@ -45,6 +45,8 @@ public class SqlQueryParser implements QueryParser {
// build ontologyQuery // build ontologyQuery
SqlQuery sqlQuery = queryStatement.getSqlQuery(); SqlQuery sqlQuery = queryStatement.getSqlQuery();
List<String> queryFields = SqlSelectHelper.getAllSelectFields(sqlQuery.getSql()); List<String> queryFields = SqlSelectHelper.getAllSelectFields(sqlQuery.getSql());
Set<String> queryAliases = SqlSelectHelper.getAliasFields(sqlQuery.getSql());
queryFields.removeAll(queryAliases);
Ontology ontology = queryStatement.getOntology(); Ontology ontology = queryStatement.getOntology();
OntologyQuery ontologyQuery = buildOntologyQuery(ontology, queryFields); OntologyQuery ontologyQuery = buildOntologyQuery(ontology, queryFields);
// check if there are fields not matched with any metric or dimension // check if there are fields not matched with any metric or dimension

View File

@@ -98,6 +98,9 @@ public abstract class S2BaseDemo implements CommandLineRunner {
@Value("${s2.demo.names:S2VisitsDemo}") @Value("${s2.demo.names:S2VisitsDemo}")
protected List<String> demoList; protected List<String> demoList;
@Value("${spring.datasource.driver-class-name}")
protected String driverClassName;
public void run(String... args) { public void run(String... args) {
demoDatabase = addDatabaseIfNotExist(); demoDatabase = addDatabaseIfNotExist();
demoChatModel = addChatModelIfNotExist(); demoChatModel = addChatModelIfNotExist();
@@ -122,10 +125,10 @@ public abstract class S2BaseDemo implements CommandLineRunner {
databaseReq.setName("S2数据库DEMO"); databaseReq.setName("S2数据库DEMO");
databaseReq.setDescription("样例数据库实例仅用于体验"); databaseReq.setDescription("样例数据库实例仅用于体验");
databaseReq.setType(DataType.H2.getFeature()); databaseReq.setType(DataType.H2.getFeature());
String profile = System.getProperty("spring.profiles.active"); if ("org.postgresql.Driver".equals(driverClassName)) {
if ("postgres".equalsIgnoreCase(profile)) {
databaseReq.setType(DataType.POSTGRESQL.getFeature()); databaseReq.setType(DataType.POSTGRESQL.getFeature());
} else if ("mysql".equalsIgnoreCase(profile)) { } else if ("com.mysql.cj.jdbc.Driver".equals(driverClassName)
|| "com.mysql.jdbc.Driver".equals(driverClassName)) {
databaseReq.setType(DataType.MYSQL.getFeature()); databaseReq.setType(DataType.MYSQL.getFeature());
} }
databaseReq.setUrl(url); databaseReq.setUrl(url);

View File

@@ -1,6 +1,6 @@
spring: spring:
datasource: datasource:
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true url: jdbc:mysql://localhost:3306/mysql?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root username: root
password: password:

View File

@@ -6,21 +6,20 @@ spring:
password: postgres password: postgres
sql: sql:
init: init:
enabled: false mode: never
mode: always
username: postgres username: postgres
password: postgres password: postgres
schema-locations: classpath:db/schema-postgres.sql,classpath:db/schema-postgres-demo.sql schema-locations: classpath:db/schema-postgres.sql,classpath:db/schema-postgres-demo.sql
data-locations: classpath:db/data-postgres.sql,classpath:db/data-postgres-demo.sql data-locations: classpath:db/data-postgres.sql,classpath:db/data-postgres-demo.sql
#s2: s2:
# embedding: embedding:
# store: store:
# provider: PGVECTOR provider: PGVECTOR
# base: base:
# url: 127.0.0.1 url: 127.0.0.1
# port: 5432 port: 5432
# databaseName: postgres databaseName: postgres
# user: postgres user: postgres
# password: postgres password: postgres
# dimension: 512 dimension: 512

View File

@@ -5,13 +5,13 @@ CREATE TABLE IF NOT EXISTS s2_user_department (
); );
CREATE TABLE IF NOT EXISTS s2_pv_uv_statis ( CREATE TABLE IF NOT EXISTS s2_pv_uv_statis (
imp_date varchar(200) NOT NULL, imp_date DATE NOT NULL,
user_name varchar(200) NOT NULL, user_name varchar(200) NOT NULL,
page varchar(200) NOT NULL page varchar(200) NOT NULL
); );
CREATE TABLE IF NOT EXISTS s2_stay_time_statis ( CREATE TABLE IF NOT EXISTS s2_stay_time_statis (
imp_date varchar(200) NOT NULL, imp_date DATE NOT NULL,
user_name varchar(200) NOT NULL, user_name varchar(200) NOT NULL,
stay_hours double precision NOT NULL, stay_hours double precision NOT NULL,
page varchar(200) NOT NULL page varchar(200) NOT NULL