(feature)(semantic) add materialization optimizer (#239)

Co-authored-by: jipengli <jipengli@tencent.com>
This commit is contained in:
jipeli
2023-10-16 22:07:45 +08:00
committed by GitHub
parent 5b8fde70ca
commit 40ba179703
126 changed files with 9172 additions and 91 deletions

View File

@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.materialization.infrastructure.mapper.MaterializationDOCustomMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="materialized_type" jdbcType="VARCHAR" property="materializedType" />
<result column="update_cycle" jdbcType="VARCHAR" property="updateCycle" />
<result column="model_id" jdbcType="BIGINT" property="modelId" />
<result column="database_id" jdbcType="BIGINT" property="databaseId" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="destination_table" jdbcType="VARCHAR" property="destinationTable" />
<result column="principals" jdbcType="VARCHAR" property="principals" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
<result column="date_info" jdbcType="LONGVARCHAR" property="dateInfo" />
<result column="entities" jdbcType="LONGVARCHAR" property="entities" />
<result column="description" jdbcType="LONGVARCHAR" property="description" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, materialized_type, update_cycle, model_id, database_id, level, status,
destination_table, principals, created_at, created_by, updated_at, updated_by
</sql>
<sql id="Blob_Column_List">
date_info, entities, description
</sql>
<select id="getMaterializationResp" parameterType="com.tencent.supersonic.semantic.api.materialization.pojo.MaterializationFilter" resultMap="ResultMapWithBLOBs">
select *
from s2_materialization
<where>
<if test="materializationId != null">
and `id` = #{materializationId}
</if>
<if test="name != null and name != ''">
and `name` = #{name}
</if>
<if test="materializedType != null">
and `materialized_type` = #{materializedType.name()}
</if>
<if test="updateCycle != null">
and update_cycle = #{updateCycle.name()}
</if>
<if test="modelId != null and modelId !=''">
and model_id = #{modelId}
</if>
<if test="databaseId != null and databaseId !=''">
and database_id= #{databaseId}
</if>
<if test="level != null and level !=''">
and level= #{level}
</if>
<if test="createdBy != null and createdBy !=''">
and created_by = #{createdBy}
</if>
<if test="destinationTable != null and destinationTable !=''">
and destination_table = #{destinationTable}
</if>
</where>
</select>
</mapper>

View File

@@ -0,0 +1,324 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.materialization.infrastructure.mapper.MaterializationDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="materialized_type" jdbcType="VARCHAR" property="materializedType" />
<result column="update_cycle" jdbcType="VARCHAR" property="updateCycle" />
<result column="model_id" jdbcType="BIGINT" property="modelId" />
<result column="database_id" jdbcType="BIGINT" property="databaseId" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="status" jdbcType="INTEGER" property="status" />
<result column="destination_table" jdbcType="VARCHAR" property="destinationTable" />
<result column="principals" jdbcType="VARCHAR" property="principals" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
<result column="date_info" jdbcType="LONGVARCHAR" property="dateInfo" />
<result column="entities" jdbcType="LONGVARCHAR" property="entities" />
<result column="description" jdbcType="LONGVARCHAR" property="description" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, materialized_type, update_cycle, model_id, database_id, level, status,
destination_table, principals, created_at, created_by, updated_at, updated_by
</sql>
<sql id="Blob_Column_List">
date_info, entities, description
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_materialization
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_materialization
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
insert into s2_materialization (id, name, materialized_type,
update_cycle, model_id, database_id,
level, status, destination_table,
principals, created_at, created_by,
updated_at, updated_by, date_info,
entities, description)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{materializedType,jdbcType=VARCHAR},
#{updateCycle,jdbcType=VARCHAR}, #{modelId,jdbcType=BIGINT}, #{databaseId,jdbcType=BIGINT},
#{level,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, #{destinationTable,jdbcType=VARCHAR},
#{principals,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR},
#{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, #{dateInfo,jdbcType=LONGVARCHAR},
#{entities,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
insert into s2_materialization
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="materializedType != null">
materialized_type,
</if>
<if test="updateCycle != null">
update_cycle,
</if>
<if test="modelId != null">
model_id,
</if>
<if test="databaseId != null">
database_id,
</if>
<if test="level != null">
level,
</if>
<if test="status != null">
status,
</if>
<if test="destinationTable != null">
destination_table,
</if>
<if test="principals != null">
principals,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="dateInfo != null">
date_info,
</if>
<if test="entities != null">
entities,
</if>
<if test="description != null">
description,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="materializedType != null">
#{materializedType,jdbcType=VARCHAR},
</if>
<if test="updateCycle != null">
#{updateCycle,jdbcType=VARCHAR},
</if>
<if test="modelId != null">
#{modelId,jdbcType=BIGINT},
</if>
<if test="databaseId != null">
#{databaseId,jdbcType=BIGINT},
</if>
<if test="level != null">
#{level,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="destinationTable != null">
#{destinationTable,jdbcType=VARCHAR},
</if>
<if test="principals != null">
#{principals,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dateInfo != null">
#{dateInfo,jdbcType=LONGVARCHAR},
</if>
<if test="entities != null">
#{entities,jdbcType=LONGVARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOExample" resultType="java.lang.Long">
select count(*) from s2_materialization
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
update s2_materialization
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="materializedType != null">
materialized_type = #{materializedType,jdbcType=VARCHAR},
</if>
<if test="updateCycle != null">
update_cycle = #{updateCycle,jdbcType=VARCHAR},
</if>
<if test="modelId != null">
model_id = #{modelId,jdbcType=BIGINT},
</if>
<if test="databaseId != null">
database_id = #{databaseId,jdbcType=BIGINT},
</if>
<if test="level != null">
level = #{level,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="destinationTable != null">
destination_table = #{destinationTable,jdbcType=VARCHAR},
</if>
<if test="principals != null">
principals = #{principals,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="dateInfo != null">
date_info = #{dateInfo,jdbcType=LONGVARCHAR},
</if>
<if test="entities != null">
entities = #{entities,jdbcType=LONGVARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDOWithBLOBs">
update s2_materialization
set name = #{name,jdbcType=VARCHAR},
materialized_type = #{materializedType,jdbcType=VARCHAR},
update_cycle = #{updateCycle,jdbcType=VARCHAR},
model_id = #{modelId,jdbcType=BIGINT},
database_id = #{databaseId,jdbcType=BIGINT},
level = #{level,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
destination_table = #{destinationTable,jdbcType=VARCHAR},
principals = #{principals,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
date_info = #{dateInfo,jdbcType=LONGVARCHAR},
entities = #{entities,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationDO">
update s2_materialization
set name = #{name,jdbcType=VARCHAR},
materialized_type = #{materializedType,jdbcType=VARCHAR},
update_cycle = #{updateCycle,jdbcType=VARCHAR},
model_id = #{modelId,jdbcType=BIGINT},
database_id = #{databaseId,jdbcType=BIGINT},
level = #{level,jdbcType=INTEGER},
status = #{status,jdbcType=INTEGER},
destination_table = #{destinationTable,jdbcType=VARCHAR},
principals = #{principals,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

View File

@@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.materialization.infrastructure.mapper.MaterializationElementDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDO">
<id column="id" jdbcType="BIGINT" property="id" />
<id column="type" jdbcType="VARCHAR" property="type" />
<id column="materialization_id" jdbcType="BIGINT" property="materializationId" />
<result column="element_type" jdbcType="VARCHAR" property="elementType" />
<result column="default_value" jdbcType="VARCHAR" property="defaultValue" />
<result column="outlier" jdbcType="VARCHAR" property="outlier" />
<result column="frequency" jdbcType="VARCHAR" property="frequency" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="status" jdbcType="INTEGER" property="status" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOWithBLOBs">
<result column="depends" jdbcType="LONGVARCHAR" property="depends" />
<result column="description" jdbcType="LONGVARCHAR" property="description" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, type, materialization_id, element_type, default_value, outlier, frequency, created_at,
created_by, updated_at, updated_by, status
</sql>
<sql id="Blob_Column_List">
depends, description
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization_element
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_materialization_element
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOKey" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization_element
where id = #{id,jdbcType=BIGINT}
and type = #{type,jdbcType=VARCHAR}
and materialization_id = #{materializationId,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOKey">
delete from s2_materialization_element
where id = #{id,jdbcType=BIGINT}
and type = #{type,jdbcType=VARCHAR}
and materialization_id = #{materializationId,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOWithBLOBs">
insert into s2_materialization_element (id, type, materialization_id,
element_type, default_value, outlier,
frequency, created_at, created_by,
updated_at, updated_by, status,
depends, description)
values (#{id,jdbcType=BIGINT}, #{type,jdbcType=VARCHAR}, #{materializationId,jdbcType=BIGINT},
#{elementType,jdbcType=VARCHAR}, #{defaultValue,jdbcType=VARCHAR}, #{outlier,jdbcType=VARCHAR},
#{frequency,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR},
#{updatedAt,jdbcType=TIMESTAMP}, #{updatedBy,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER},
#{depends,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOWithBLOBs">
insert into s2_materialization_element
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="type != null">
type,
</if>
<if test="materializationId != null">
materialization_id,
</if>
<if test="elementType != null">
element_type,
</if>
<if test="defaultValue != null">
default_value,
</if>
<if test="outlier != null">
outlier,
</if>
<if test="frequency != null">
frequency,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="status != null">
status,
</if>
<if test="depends != null">
depends,
</if>
<if test="description != null">
description,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="materializationId != null">
#{materializationId,jdbcType=BIGINT},
</if>
<if test="elementType != null">
#{elementType,jdbcType=VARCHAR},
</if>
<if test="defaultValue != null">
#{defaultValue,jdbcType=VARCHAR},
</if>
<if test="outlier != null">
#{outlier,jdbcType=VARCHAR},
</if>
<if test="frequency != null">
#{frequency,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="status != null">
#{status,jdbcType=INTEGER},
</if>
<if test="depends != null">
#{depends,jdbcType=LONGVARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOExample" resultType="java.lang.Long">
select count(*) from s2_materialization_element
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOWithBLOBs">
update s2_materialization_element
<set>
<if test="elementType != null">
element_type = #{elementType,jdbcType=VARCHAR},
</if>
<if test="defaultValue != null">
default_value = #{defaultValue,jdbcType=VARCHAR},
</if>
<if test="outlier != null">
outlier = #{outlier,jdbcType=VARCHAR},
</if>
<if test="frequency != null">
frequency = #{frequency,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="depends != null">
depends = #{depends,jdbcType=LONGVARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
and type = #{type,jdbcType=VARCHAR}
and materialization_id = #{materializationId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDOWithBLOBs">
update s2_materialization_element
set element_type = #{elementType,jdbcType=VARCHAR},
default_value = #{defaultValue,jdbcType=VARCHAR},
outlier = #{outlier,jdbcType=VARCHAR},
frequency = #{frequency,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
depends = #{depends,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
and type = #{type,jdbcType=VARCHAR}
and materialization_id = #{materializationId,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationElementDO">
update s2_materialization_element
set element_type = #{elementType,jdbcType=VARCHAR},
default_value = #{defaultValue,jdbcType=VARCHAR},
outlier = #{outlier,jdbcType=VARCHAR},
frequency = #{frequency,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
and type = #{type,jdbcType=VARCHAR}
and materialization_id = #{materializationId,jdbcType=BIGINT}
</update>
<update id="cleanMaterializationElement">
delete from s2_materialization_element
where materialization_id = #{materializationId}
</update>
</mapper>

View File

@@ -0,0 +1,336 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tencent.supersonic.semantic.materialization.infrastructure.mapper.MaterializationRecordDOMapper">
<resultMap id="BaseResultMap" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="materialization_id" jdbcType="BIGINT" property="materializationId" />
<result column="element_type" jdbcType="VARCHAR" property="elementType" />
<result column="element_id" jdbcType="BIGINT" property="elementId" />
<result column="element_name" jdbcType="VARCHAR" property="elementName" />
<result column="data_time" jdbcType="VARCHAR" property="dataTime" />
<result column="state" jdbcType="VARCHAR" property="state" />
<result column="task_id" jdbcType="VARCHAR" property="taskId" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="created_by" jdbcType="VARCHAR" property="createdBy" />
<result column="updated_by" jdbcType="VARCHAR" property="updatedBy" />
<result column="retry_count" jdbcType="BIGINT" property="retryCount" />
<result column="source_count" jdbcType="BIGINT" property="sourceCount" />
<result column="sink_count" jdbcType="BIGINT" property="sinkCount" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
<result column="message" jdbcType="LONGVARCHAR" property="message" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, materialization_id, element_type, element_id, element_name, data_time, state,
task_id, created_at, updated_at, created_by, updated_by, retry_count, source_count,
sink_count
</sql>
<sql id="Blob_Column_List">
message
</sql>
<select id="selectByExampleWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDOExample" resultMap="ResultMapWithBLOBs">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDOExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from s2_materialization_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from s2_materialization_record
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from s2_materialization_record
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
insert into s2_materialization_record (id, materialization_id, element_type,
element_id, element_name, data_time,
state, task_id, created_at,
updated_at, created_by, updated_by,
retry_count, source_count, sink_count,
message)
values (#{id,jdbcType=BIGINT}, #{materializationId,jdbcType=BIGINT}, #{elementType,jdbcType=VARCHAR},
#{elementId,jdbcType=BIGINT}, #{elementName,jdbcType=VARCHAR}, #{dataTime,jdbcType=VARCHAR},
#{state,jdbcType=VARCHAR}, #{taskId,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP},
#{updatedAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}, #{updatedBy,jdbcType=VARCHAR},
#{retryCount,jdbcType=BIGINT}, #{sourceCount,jdbcType=BIGINT}, #{sinkCount,jdbcType=BIGINT},
#{message,jdbcType=LONGVARCHAR})
ON DUPLICATE KEY UPDATE
updated_at = #{updatedAt}, retry_count = retry_count + 1
</insert>
<insert id="insertSelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
insert into s2_materialization_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="materializationId != null">
materialization_id,
</if>
<if test="elementType != null">
element_type,
</if>
<if test="elementId != null">
element_id,
</if>
<if test="elementName != null">
element_name,
</if>
<if test="dataTime != null">
data_time,
</if>
<if test="state != null">
state,
</if>
<if test="taskId != null">
task_id,
</if>
<if test="createdAt != null">
created_at,
</if>
<if test="updatedAt != null">
updated_at,
</if>
<if test="createdBy != null">
created_by,
</if>
<if test="updatedBy != null">
updated_by,
</if>
<if test="retryCount != null">
retry_count,
</if>
<if test="sourceCount != null">
source_count,
</if>
<if test="sinkCount != null">
sink_count,
</if>
<if test="message != null">
message,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="materializationId != null">
#{materializationId,jdbcType=BIGINT},
</if>
<if test="elementType != null">
#{elementType,jdbcType=VARCHAR},
</if>
<if test="elementId != null">
#{elementId,jdbcType=BIGINT},
</if>
<if test="elementName != null">
#{elementName,jdbcType=VARCHAR},
</if>
<if test="dataTime != null">
#{dataTime,jdbcType=VARCHAR},
</if>
<if test="state != null">
#{state,jdbcType=VARCHAR},
</if>
<if test="taskId != null">
#{taskId,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
#{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
#{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
#{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedBy != null">
#{updatedBy,jdbcType=VARCHAR},
</if>
<if test="retryCount != null">
#{retryCount,jdbcType=BIGINT},
</if>
<if test="sourceCount != null">
#{sourceCount,jdbcType=BIGINT},
</if>
<if test="sinkCount != null">
#{sinkCount,jdbcType=BIGINT},
</if>
<if test="message != null">
#{message,jdbcType=LONGVARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDOExample" resultType="java.lang.Long">
select count(*) from s2_materialization_record
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByPrimaryKeySelective" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
update s2_materialization_record
<set>
<if test="materializationId != null">
materialization_id = #{materializationId,jdbcType=BIGINT},
</if>
<if test="elementType != null">
element_type = #{elementType,jdbcType=VARCHAR},
</if>
<if test="elementId != null">
element_id = #{elementId,jdbcType=BIGINT},
</if>
<if test="elementName != null">
element_name = #{elementName,jdbcType=VARCHAR},
</if>
<if test="dataTime != null">
data_time = #{dataTime,jdbcType=VARCHAR},
</if>
<if test="state != null">
state = #{state,jdbcType=VARCHAR},
</if>
<if test="taskId != null">
task_id = #{taskId,jdbcType=VARCHAR},
</if>
<if test="createdAt != null">
created_at = #{createdAt,jdbcType=TIMESTAMP},
</if>
<if test="updatedAt != null">
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
</if>
<if test="createdBy != null">
created_by = #{createdBy,jdbcType=VARCHAR},
</if>
<if test="updatedBy != null">
updated_by = #{updatedBy,jdbcType=VARCHAR},
</if>
<if test="retryCount != null">
retry_count = #{retryCount,jdbcType=BIGINT},
</if>
<if test="sourceCount != null">
source_count = #{sourceCount,jdbcType=BIGINT},
</if>
<if test="sinkCount != null">
sink_count = #{sinkCount,jdbcType=BIGINT},
</if>
<if test="message != null">
message = #{message,jdbcType=LONGVARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
update s2_materialization_record
set materialization_id = #{materializationId,jdbcType=BIGINT},
element_type = #{elementType,jdbcType=VARCHAR},
element_id = #{elementId,jdbcType=BIGINT},
element_name = #{elementName,jdbcType=VARCHAR},
data_time = #{dataTime,jdbcType=VARCHAR},
state = #{state,jdbcType=VARCHAR},
task_id = #{taskId,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_by = #{updatedBy,jdbcType=VARCHAR},
retry_count = #{retryCount,jdbcType=BIGINT},
source_count = #{sourceCount,jdbcType=BIGINT},
sink_count = #{sinkCount,jdbcType=BIGINT},
message = #{message,jdbcType=LONGVARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByBizName" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
update s2_materialization_record
set
element_id = #{elementId,jdbcType=BIGINT},
state = #{state,jdbcType=VARCHAR},
task_id = #{taskId,jdbcType=VARCHAR},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
updated_by = #{updatedBy,jdbcType=VARCHAR},
retry_count = #{retryCount,jdbcType=BIGINT},
source_count = #{sourceCount,jdbcType=BIGINT},
sink_count = #{sinkCount,jdbcType=BIGINT},
message = #{message,jdbcType=LONGVARCHAR}
where
materialization_id = #{materializationId}
AND element_type = #{elementType}
AND element_name = #{elementName}
AND data_time = #{dataTime}
</update>
<update id="updateByPrimaryKey" parameterType="com.tencent.supersonic.semantic.materialization.domain.dataobject.MaterializationRecordDO">
update s2_materialization_record
set materialization_id = #{materializationId,jdbcType=BIGINT},
element_type = #{elementType,jdbcType=VARCHAR},
element_id = #{elementId,jdbcType=BIGINT},
element_name = #{elementName,jdbcType=VARCHAR},
data_time = #{dataTime,jdbcType=VARCHAR},
state = #{state,jdbcType=VARCHAR},
task_id = #{taskId,jdbcType=VARCHAR},
created_at = #{createdAt,jdbcType=TIMESTAMP},
updated_at = #{updatedAt,jdbcType=TIMESTAMP},
created_by = #{createdBy,jdbcType=VARCHAR},
updated_by = #{updatedBy,jdbcType=VARCHAR},
retry_count = #{retryCount,jdbcType=BIGINT},
source_count = #{sourceCount,jdbcType=BIGINT},
sink_count = #{sinkCount,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>