diff --git a/docker/Dockerfile b/docker/Dockerfile index 330c70c32..72caa801f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,5 @@ # Use an official OpenJDK runtime as a parent image -FROM openjdk:8-jdk +FROM openjdk:21-jdk-bullseye # Set the working directory in the container WORKDIR /usr/src/app @@ -7,8 +7,6 @@ WORKDIR /usr/src/app # Argument to pass in the supersonic version at build time ARG SUPERSONIC_VERSION -RUN apt-get update - # Install necessary packages, including Postgres client RUN apt-get update && apt-get install -y postgresql-client diff --git a/docker/docker-compose-run.sh b/docker/docker-compose-run.sh index 7a515ba56..f994d0e7b 100644 --- a/docker/docker-compose-run.sh +++ b/docker/docker-compose-run.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -SUPERSONIC_VERSION=0.9.10-SNAPSHOT docker-compose -f docker-compose.yml -p supersonic up \ No newline at end of file +SUPERSONIC_VERSION=latest docker-compose -f docker-compose.yml -p supersonic up \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 9b7b0c10a..d4ef80a34 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -11,8 +11,8 @@ services: POSTGRES_PASSWORD: supersonic_password ports: - "15432:5432" - volumes: - - postgres_data:/var/lib/postgresql +# volumes: +# - postgres_data:/var/lib/postgresql networks: - supersonic_network dns: @@ -72,9 +72,9 @@ services: - 114.114.114.114 - 8.8.8.8 - 8.8.4.4 - volumes: + #volumes: #1.Named Volumes are best for persistent data managed by Docker. - - supersonic_data:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest} + #- supersonic_data:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest} #2.Bind Mounts are suitable for frequent modifications and debugging. # - ./conf/application-prd.yaml:/usr/src/app/supersonic-standalone-${SUPERSONIC_VERSION:-latest}/conf/application-prd.yaml #3.Detailed Bind Mounts offer more control over the mount behavior. @@ -84,9 +84,9 @@ services: # bind: # propagation: rprivate # create_host_path: true -volumes: - postgres_data: - supersonic_data: +#volumes: +# postgres_data: +# supersonic_data: networks: supersonic_network: \ No newline at end of file diff --git a/docker/docker-publish.sh b/docker/docker-publish.sh index aadb73198..b17292bf5 100644 --- a/docker/docker-publish.sh +++ b/docker/docker-publish.sh @@ -12,6 +12,7 @@ TAGS="latest" # If VERSION is provided, add it to TAGS and tag the image as latest if [ -n "$VERSION" ]; then TAGS="$TAGS $VERSION" + echo "Tagging Docker images $IMAGE_NAME:$VERSION to $IMAGE_NAME:latest" docker tag $IMAGE_NAME:$VERSION $IMAGE_NAME:latest fi diff --git a/headless/server/src/main/java/com/tencent/supersonic/headless/server/persistence/dataobject/QueryStatDO.java b/headless/server/src/main/java/com/tencent/supersonic/headless/server/persistence/dataobject/QueryStatDO.java index e6c39acde..89c1a8113 100644 --- a/headless/server/src/main/java/com/tencent/supersonic/headless/server/persistence/dataobject/QueryStatDO.java +++ b/headless/server/src/main/java/com/tencent/supersonic/headless/server/persistence/dataobject/QueryStatDO.java @@ -28,7 +28,7 @@ public class QueryStatDO { private String queryStructCmd; @TableField("struct_cmd_md5") private String queryStructCmdMd5; - @TableField("`sql`") + @TableField("query_sql") private String sql; private String sqlMd5; private String queryEngine; diff --git a/launchers/standalone/src/main/java/com/tencent/supersonic/demo/S2VisitsDemo.java b/launchers/standalone/src/main/java/com/tencent/supersonic/demo/S2VisitsDemo.java index 432490ea3..381afd6ab 100644 --- a/launchers/standalone/src/main/java/com/tencent/supersonic/demo/S2VisitsDemo.java +++ b/launchers/standalone/src/main/java/com/tencent/supersonic/demo/S2VisitsDemo.java @@ -16,54 +16,21 @@ import com.tencent.supersonic.common.pojo.ChatApp; import com.tencent.supersonic.common.pojo.JoinCondition; import com.tencent.supersonic.common.pojo.ModelRela; -import com.tencent.supersonic.common.pojo.enums.AggOperatorEnum; -import com.tencent.supersonic.common.pojo.enums.AggregateTypeEnum; -import com.tencent.supersonic.common.pojo.enums.AppModule; -import com.tencent.supersonic.common.pojo.enums.FilterOperatorEnum; -import com.tencent.supersonic.common.pojo.enums.SensitiveLevelEnum; -import com.tencent.supersonic.common.pojo.enums.StatusEnum; -import com.tencent.supersonic.common.pojo.enums.TypeEnums; +import com.tencent.supersonic.common.pojo.enums.*; import com.tencent.supersonic.common.util.ChatAppManager; import com.tencent.supersonic.common.util.JsonUtil; -import com.tencent.supersonic.headless.api.pojo.DataSetDetail; -import com.tencent.supersonic.headless.api.pojo.DataSetModelConfig; -import com.tencent.supersonic.headless.api.pojo.Dimension; -import com.tencent.supersonic.headless.api.pojo.DimensionTimeTypeParams; -import com.tencent.supersonic.headless.api.pojo.Field; -import com.tencent.supersonic.headless.api.pojo.FieldParam; -import com.tencent.supersonic.headless.api.pojo.Identify; -import com.tencent.supersonic.headless.api.pojo.Measure; -import com.tencent.supersonic.headless.api.pojo.MeasureParam; -import com.tencent.supersonic.headless.api.pojo.MetricDefineByFieldParams; -import com.tencent.supersonic.headless.api.pojo.MetricDefineByMeasureParams; -import com.tencent.supersonic.headless.api.pojo.MetricDefineByMetricParams; -import com.tencent.supersonic.headless.api.pojo.MetricParam; -import com.tencent.supersonic.headless.api.pojo.ModelDetail; +import com.tencent.supersonic.headless.api.pojo.*; import com.tencent.supersonic.headless.api.pojo.enums.DimensionType; import com.tencent.supersonic.headless.api.pojo.enums.IdentifyType; import com.tencent.supersonic.headless.api.pojo.enums.MetricDefineType; import com.tencent.supersonic.headless.api.pojo.enums.SemanticType; -import com.tencent.supersonic.headless.api.pojo.request.DataSetReq; -import com.tencent.supersonic.headless.api.pojo.request.DimensionReq; -import com.tencent.supersonic.headless.api.pojo.request.DomainReq; -import com.tencent.supersonic.headless.api.pojo.request.MetricReq; -import com.tencent.supersonic.headless.api.pojo.request.ModelReq; -import com.tencent.supersonic.headless.api.pojo.request.TermReq; -import com.tencent.supersonic.headless.api.pojo.response.DataSetResp; -import com.tencent.supersonic.headless.api.pojo.response.DatabaseResp; -import com.tencent.supersonic.headless.api.pojo.response.DimensionResp; -import com.tencent.supersonic.headless.api.pojo.response.DomainResp; -import com.tencent.supersonic.headless.api.pojo.response.MetricResp; -import com.tencent.supersonic.headless.api.pojo.response.ModelResp; +import com.tencent.supersonic.headless.api.pojo.request.*; +import com.tencent.supersonic.headless.api.pojo.response.*; import lombok.extern.slf4j.Slf4j; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Map; +import java.util.*; @Component @Slf4j @@ -86,9 +53,7 @@ public void doRun() { // create metrics and dimensions DimensionResp departmentDimension = getDimension("department", userModel); - MetricResp metricUv = addMetric_uv(pvUvModel, departmentDimension); MetricResp metricPv = getMetric("pv", pvUvModel); - addMetric_pv_avg(metricPv, metricUv, departmentDimension, pvUvModel); DimensionResp pageDimension = getDimension("page", stayTimeModel); updateDimension(stayTimeModel, pageDimension); @@ -397,31 +362,6 @@ private MetricResp addMetric_uv(ModelResp uvModel, DimensionResp departmentDimen return metricService.createMetric(metricReq, defaultUser); } - private MetricResp addMetric_pv_avg(MetricResp metricPv, MetricResp metricUv, - DimensionResp departmentDimension, ModelResp pvModel) throws Exception { - MetricReq metricReq = new MetricReq(); - metricReq.setModelId(pvModel.getId()); - metricReq.setName("人均访问次数"); - metricReq.setBizName("pv_avg"); - metricReq.setSensitiveLevel(SensitiveLevelEnum.HIGH.getCode()); - metricReq.setDescription("每个用户平均访问的次数"); - metricReq.setClassifications(Collections.singletonList("核心指标")); - metricReq.setAlias("平均访问次数"); - MetricDefineByMetricParams metricTypeParams = new MetricDefineByMetricParams(); - metricTypeParams.setExpr("pv/uv"); - List metrics = new ArrayList<>(); - MetricParam pv = new MetricParam(metricPv.getId(), metricPv.getBizName()); - MetricParam uv = new MetricParam(metricUv.getId(), metricUv.getBizName()); - metrics.add(pv); - metrics.add(uv); - metricTypeParams.setMetrics(metrics); - metricReq.setMetricDefineByMetricParams(metricTypeParams); - metricReq.setMetricDefineType(MetricDefineType.METRIC); - metricReq.setRelateDimension( - getRelateDimension(Lists.newArrayList(departmentDimension.getId()))); - return metricService.createMetric(metricReq, defaultUser); - } - private DataSetResp addDataSet(DomainResp s2Domain) { DataSetReq dataSetReq = new DataSetReq(); dataSetReq.setName("超音数数据集"); diff --git a/launchers/standalone/src/main/resources/config.update/sql-update.sql b/launchers/standalone/src/main/resources/config.update/sql-update.sql index 00ea06110..cfd366c3f 100644 --- a/launchers/standalone/src/main/resources/config.update/sql-update.sql +++ b/launchers/standalone/src/main/resources/config.update/sql-update.sql @@ -404,4 +404,5 @@ ALTER TABLE s2_query_stat_info RENAME COLUMN `user` TO `query_user`; ALTER TABLE s2_chat_context RENAME COLUMN `user` TO `query_user`; --20241226 -alter table s2_chat_memory add column `query_id` BIGINT DEFAULT NULL; \ No newline at end of file +ALTER TABLE s2_chat_memory add column `query_id` BIGINT DEFAULT NULL; +ALTER TABLE s2_query_stat_info RENAME COLUMN `sql` TO `query_sql`; \ No newline at end of file diff --git a/launchers/standalone/src/main/resources/db/schema-h2.sql b/launchers/standalone/src/main/resources/db/schema-h2.sql index 606d56966..bf6335102 100644 --- a/launchers/standalone/src/main/resources/db/schema-h2.sql +++ b/launchers/standalone/src/main/resources/db/schema-h2.sql @@ -299,7 +299,7 @@ CREATE TABLE IF NOT EXISTS `s2_query_stat_info` ( `sql_cmd_md5` varchar(200) DEFAULT NULL, -- sql type request parameter md5 `query_struct_cmd`LONGVARCHAR , -- struct type request parameter `struct_cmd_md5` varchar(200) DEFAULT NULL, -- struct type request parameter md5值 - `sql`LONGVARCHAR , + `query_sql` LONGVARCHAR , `sql_md5` varchar(200) DEFAULT NULL, -- sql md5 `query_engine` varchar(20) DEFAULT NULL, `elapsed_ms` bigINT DEFAULT NULL, diff --git a/launchers/standalone/src/main/resources/db/schema-mysql.sql b/launchers/standalone/src/main/resources/db/schema-mysql.sql index c24e73ffe..6143b19e4 100644 --- a/launchers/standalone/src/main/resources/db/schema-mysql.sql +++ b/launchers/standalone/src/main/resources/db/schema-mysql.sql @@ -336,7 +336,7 @@ CREATE TABLE IF NOT EXISTS `s2_query_stat_info` ( `sql_cmd_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值', `query_struct_cmd` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的struct', `struct_cmd_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值', - `sql` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的sql', + `query_sql` mediumtext COLLATE utf8mb4_unicode_ci COMMENT '对应查询的sql', `sql_md5` varchar(200) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'sql md5值', `query_engine` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '查询引擎', `elapsed_ms` bigint(10) DEFAULT NULL COMMENT '查询耗时', diff --git a/launchers/standalone/src/main/resources/db/schema-postgres.sql b/launchers/standalone/src/main/resources/db/schema-postgres.sql index 284268301..a57944216 100644 --- a/launchers/standalone/src/main/resources/db/schema-postgres.sql +++ b/launchers/standalone/src/main/resources/db/schema-postgres.sql @@ -416,7 +416,7 @@ CREATE TABLE IF NOT EXISTS s2_query_stat_info ( sql_cmd_md5 varchar(200) DEFAULT NULL, query_struct_cmd text, struct_cmd_md5 varchar(200) DEFAULT NULL, - sql text, + query_sql text, sql_md5 varchar(200) DEFAULT NULL, query_engine varchar(20) DEFAULT NULL, elapsed_ms bigint DEFAULT NULL, diff --git a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/ModelSchemaTest.java b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/ModelSchemaTest.java index 83915bb5a..5b1491deb 100644 --- a/launchers/standalone/src/test/java/com/tencent/supersonic/headless/ModelSchemaTest.java +++ b/launchers/standalone/src/test/java/com/tencent/supersonic/headless/ModelSchemaTest.java @@ -24,7 +24,7 @@ void testGetUnAvailableItem() { fieldRemovedReq.setModelId(2L); fieldRemovedReq.setFields(Lists.newArrayList("pv")); UnAvailableItemResp unAvailableItemResp = modelService.getUnAvailableItem(fieldRemovedReq); - List expectedUnAvailableMetricId = Lists.newArrayList(1L, 4L); + List expectedUnAvailableMetricId = Lists.newArrayList(1L); List actualUnAvailableMetricId = unAvailableItemResp.getMetricResps().stream().map(MetricResp::getId) .sorted(Comparator.naturalOrder()).collect(Collectors.toList());