Skip to content

Commit

Permalink
load user's and shared udf (#4417)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarexixi authored Mar 27, 2023
1 parent bab4b47 commit 1004308
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ List<UDFInfoVo> getUDFInfoByTreeId(
Long treeId, String userName, Collection<Integer> categoryCodes);

List<UDFInfoVo> getUDFInfoByIds(
@Param("ids") Long[] ids, @Param("categoryCodes") Collection<Integer> categoryCodes);
@Param("username") String username,
@Param("ids") Long[] ids,
@Param("categoryCodes") Collection<Integer> categoryCodes);

List<UDFInfo> getLoadedUDFs(String userName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ List<UDFInfoVo> getUDFSByTreeIdAndUser(Long treeId, String userName, String cate
List<UDFInfoVo> getUDFInfoByTreeId(Long treeId, String userName, String category)
throws UDFException;

List<UDFInfoVo> getUDFInfoByIds(Long[] ids, String category) throws UDFException;
List<UDFInfoVo> getUDFInfoByIds(String username, Long[] ids, String category) throws UDFException;

Map<String, List<String>> generateInitSql(String userName) throws UDFException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ public List<UDFInfoVo> getUDFInfoByTreeId(Long treeId, String userName, String c
}

@Override
public List<UDFInfoVo> getUDFInfoByIds(Long[] ids, String category) {
public List<UDFInfoVo> getUDFInfoByIds(String username, Long[] ids, String category) {
if (ids == null || ids.length == 0) {
return new ArrayList<>(0);
}
return udfDao.getUDFInfoByIds(ids, categoryToCodes.get(category));
return udfDao.getUDFInfoByIds(username, ids, categoryToCodes.get(category));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,25 @@
</select>

<select id="getUDFInfoByIds" resultType="org.apache.linkis.udf.vo.UDFInfoVo">
select pub.*, puv.path, puv.register_format, puv.use_format, puv.bml_resource_id, puv.bml_resource_version, puv.description
from
linkis_ps_udf_baseinfo pub
join (
select udf_id, max(bml_resource_version) as max_version
from linkis_ps_udf_version
where udf_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
group by udf_id
) puvg on pub.id=puvg.udf_id
join linkis_ps_udf_version puv on puvg.udf_id=puv.udf_id and puvg.max_version=puv.bml_resource_version
where udf_type in <foreach collection="categoryCodes" open="(" separator="," close=")" item="item">#{item}</foreach>
select pub.*,
puv.path,
puv.register_format,
puv.use_format,
puv.bml_resource_id,
puv.bml_resource_version,
puv.description
from (select *
from linkis_ps_udf_baseinfo
where id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
and udf_type in <foreach collection="categoryCodes" open="(" separator="," close=")" item="item">#{item}</foreach>
) pub
join (select udf_id, max(bml_resource_version) as max_version
from linkis_ps_udf_version
where udf_id in <foreach collection="ids" open="(" separator="," close=")" item="item">#{item}</foreach>
group by udf_id) puvg on pub.id = puvg.udf_id
join linkis_ps_udf_version puv on puvg.udf_id = puv.udf_id and puvg.max_version = puv.bml_resource_version
left join (select udf_id from linkis_ps_udf_shared_info where user_name = #{username}) pusi on pub.id = pusi.udf_id
where pub.create_user = #{username} or pusi.udf_id is not null
</select>

<select id="getLoadedUDFs" resultMap="UDFInfoMap">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class UdfReceiver extends Receiver {
val udfTree = udfTreeService.getTreeById(treeId, userName, treeType, treeCategory)
new ResponseUdfTree(udfTree)
case RequestUdfIds(userName, udfIds, treeCategory) =>
val udfs = udfService.getUDFInfoByIds(udfIds.map(id => new lang.Long(id)), treeCategory)
val udfs =
udfService.getUDFInfoByIds(userName, udfIds.map(id => new lang.Long(id)), treeCategory)
new ResponseUdfs(udfs)
case _ =>
}
Expand Down

0 comments on commit 1004308

Please sign in to comment.