mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 03:58:14 +00:00
[fix][headless]Fix a set of known issues.
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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())) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user