[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
try {
if (parseInfo.getDateInfo() == null && !CollectionUtils.isEmpty(expressions)) {
if (!CollectionUtils.isEmpty(expressions)) {
parseInfo.setDateInfo(extractDateFilter(expressions, dsSchema));
}
} catch (Exception e) {

View File

@@ -144,6 +144,15 @@ public class SqlSelectHelper {
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) {
if (selectStatement == null) {
return null;

View File

@@ -59,9 +59,15 @@ public class DateConf {
return false;
}
DateConf dateConf = (DateConf) o;
return dateMode == dateConf.dateMode && Objects.equals(startDate, dateConf.startDate)
&& Objects.equals(endDate, dateConf.endDate) && Objects.equals(unit, dateConf.unit)
&& Objects.equals(period, dateConf.period);
if (dateMode != dateConf.dateMode) {
return false;
}
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

View File

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

View File

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

View File

@@ -45,6 +45,8 @@ public class SqlQueryParser implements QueryParser {
// build ontologyQuery
SqlQuery sqlQuery = queryStatement.getSqlQuery();
List<String> queryFields = SqlSelectHelper.getAllSelectFields(sqlQuery.getSql());
Set<String> queryAliases = SqlSelectHelper.getAliasFields(sqlQuery.getSql());
queryFields.removeAll(queryAliases);
Ontology ontology = queryStatement.getOntology();
OntologyQuery ontologyQuery = buildOntologyQuery(ontology, queryFields);
// 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}")
protected List<String> demoList;
@Value("${spring.datasource.driver-class-name}")
protected String driverClassName;
public void run(String... args) {
demoDatabase = addDatabaseIfNotExist();
demoChatModel = addChatModelIfNotExist();
@@ -122,10 +125,10 @@ public abstract class S2BaseDemo implements CommandLineRunner {
databaseReq.setName("S2数据库DEMO");
databaseReq.setDescription("样例数据库实例仅用于体验");
databaseReq.setType(DataType.H2.getFeature());
String profile = System.getProperty("spring.profiles.active");
if ("postgres".equalsIgnoreCase(profile)) {
if ("org.postgresql.Driver".equals(driverClassName)) {
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.setUrl(url);

View File

@@ -1,6 +1,6 @@
spring:
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
username: root
password:

View File

@@ -6,21 +6,20 @@ spring:
password: postgres
sql:
init:
enabled: false
mode: always
mode: never
username: postgres
password: postgres
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
#s2:
# embedding:
# store:
# provider: PGVECTOR
# base:
# url: 127.0.0.1
# port: 5432
# databaseName: postgres
# user: postgres
# password: postgres
# dimension: 512
s2:
embedding:
store:
provider: PGVECTOR
base:
url: 127.0.0.1
port: 5432
databaseName: postgres
user: postgres
password: postgres
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 (
imp_date varchar(200) NOT NULL,
imp_date DATE NOT NULL,
user_name varchar(200) NOT NULL,
page varchar(200) NOT NULL
);
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,
stay_hours double precision NOT NULL,
page varchar(200) NOT NULL