-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiaojiebao
committed
Feb 5, 2024
1 parent
3442dbe
commit dd43519
Showing
7 changed files
with
528 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
...c/main/java/com/datastrato/gravitino/storage/relation/mysql/mapper/CatalogMetaMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/* | ||
* Copyright 2024 Datastrato Pvt Ltd. | ||
* This software is licensed under the Apache License version 2. | ||
*/ | ||
|
||
package com.datastrato.gravitino.storage.relation.mysql.mapper; | ||
|
||
import com.datastrato.gravitino.storage.relation.mysql.po.CatalogPO; | ||
import java.util.List; | ||
import org.apache.ibatis.annotations.Delete; | ||
import org.apache.ibatis.annotations.Insert; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.apache.ibatis.annotations.Select; | ||
import org.apache.ibatis.annotations.Update; | ||
|
||
public interface CatalogMetaMapper { | ||
String TABLE_NAME = "catalog_meta"; | ||
|
||
@Select( | ||
"SELECT id, catalog_name as catalogName, metalake_id as metalakeId," | ||
+ " type, provider, catalog_comment as catalogComment," | ||
+ " properties, audit_info as auditInfo" | ||
+ " FROM " | ||
+ TABLE_NAME) | ||
List<CatalogPO> listCatalogPOsByMetalakeId(@Param("metalakeId") Long metalakeId); | ||
|
||
@Select( | ||
"SELECT id FROM " | ||
+ TABLE_NAME | ||
+ " WHERE catalog_name = #{catalogName} and metalake_id = #{metalakeId}") | ||
Long selectCatalogIdByNameAndMetalakeId( | ||
@Param("catalogName") String name, @Param("metalakeId") Long metalakeId); | ||
|
||
@Select( | ||
"SELECT id, catalog_name as catalogName," | ||
+ " metalake_id as metalakeId, type, provider," | ||
+ " catalog_comment as catalogComment, properties," | ||
+ " audit_info as auditInfo" | ||
+ " FROM " | ||
+ TABLE_NAME | ||
+ " WHERE catalog_name = #{catalogName} and metalake_id = #{metalakeId}") | ||
CatalogPO selectCatalogMetaByNameAndMetalakeId( | ||
@Param("catalogName") String name, @Param("metalakeId") Long metalakeId); | ||
|
||
@Insert( | ||
"INSERT INTO " | ||
+ TABLE_NAME | ||
+ "(id, catalog_name, metalake_id, type, provider, catalog_comment, properties, audit_info)" | ||
+ " VALUES(" | ||
+ " #{catalogMeta.id}," | ||
+ " #{catalogMeta.catalogName}," | ||
+ " #{catalogMeta.metalakeId}," | ||
+ " #{catalogMeta.type}," | ||
+ " #{catalogMeta.provider}," | ||
+ " #{catalogMeta.catalogComment}," | ||
+ " #{catalogMeta.properties}," | ||
+ " #{catalogMeta.auditInfo}" | ||
+ " )") | ||
void insertCatalogMeta(@Param("catalogMeta") CatalogPO catalogPO); | ||
|
||
@Insert( | ||
"INSERT INTO " | ||
+ TABLE_NAME | ||
+ "(id, catalog_name, metalake_id, type, provider, metalake_comment, properties, audit_info)" | ||
+ " VALUES(" | ||
+ " #{catalogMeta.id}," | ||
+ " #{catalogMeta.catalogName}," | ||
+ " #{catalogMeta.metalakeId}," | ||
+ " #{catalogMeta.type}," | ||
+ " #{catalogMeta.provider}," | ||
+ " #{catalogMeta.catalogComment}," | ||
+ " #{catalogMeta.properties}," | ||
+ " #{catalogMeta.auditInfo}" | ||
+ " )" | ||
+ " ON DUPLICATE KEY UPDATE" | ||
+ " catalog_name = #{catalogMeta.catalogName}," | ||
+ " metalake_id = #{catalogMeta.metalakeId}," | ||
+ " type = #{catalogMeta.type}," | ||
+ " provider = #{catalogMeta.provider}," | ||
+ " catalog_comment = #{catalogMeta.catalogComment}," | ||
+ " properties = #{catalogMeta.properties}," | ||
+ " audit_info = #{catalogMeta.auditInfo}") | ||
void insertCatalogMetaWithUpdate(@Param("catalogMeta") CatalogPO catalogPO); | ||
|
||
@Update( | ||
"UPDATE " | ||
+ TABLE_NAME | ||
+ " SET catalog_name = #{newCatalogMeta.metalakeName}," | ||
+ " metalake_id = #{newCatalogMeta.metalakeId}," | ||
+ " type = #{newCatalogMeta.type}," | ||
+ " provider = #{newCatalogMeta.provider}," | ||
+ " catalog_comment = #{newCatalogMeta.catalogComment}," | ||
+ " properties = #{newCatalogMeta.properties}," | ||
+ " audit_info = #{newCatalogMeta.auditInfo}" | ||
+ " WHERE id = #{oldCatalogMeta.id}" | ||
+ " and catalog_name = #{oldCatalogMeta.catalogName}" | ||
+ " and metalake_id = #{oldCatalogMeta.metalakeId}" | ||
+ " and type = #{oldCatalogMeta.type}" | ||
+ " and provider = #{oldCatalogMeta.provider}" | ||
+ " and catalog_comment = #{oldCatalogMeta.catalogComment}" | ||
+ " and properties = #{oldCatalogMeta.properties}" | ||
+ " and audit_info = #{oldCatalogMeta.auditInfo}") | ||
void updateCatalogMeta( | ||
@Param("newCatalogMeta") CatalogPO newCatalogPO, | ||
@Param("oldCatalogMeta") CatalogPO oldCatalogPO); | ||
|
||
@Delete("DELETE FROM " + TABLE_NAME + " WHERE id = #{id}") | ||
Integer deleteCatalogMetasById(@Param("id") Long id); | ||
|
||
@Delete("DELETE FROM " + TABLE_NAME + " WHERE metalake_id = #{metalakeId}") | ||
Integer deleteCatalogMetasByMetalakeId(@Param("metalakeId") Long metalakeId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.