|
@@ -75,25 +75,31 @@ public class OdpsSqlInfoServiceImpl extends ServiceImpl<OdpsSqlInfoMapper, OdpsS
|
|
|
@Override
|
|
|
public OdpsSqlInfoVO registerSql(RegisterSqlVO registerSqlVO) {
|
|
|
String tn = registerSqlVO.getTn();
|
|
|
+ String allSql = null;
|
|
|
+ if (StringUtils.isEmpty(tn)) {
|
|
|
+ allSql = registerSqlVO.getSql();
|
|
|
+ } else {
|
|
|
+ checkColumns(registerSqlVO.getColumns(), tn);
|
|
|
+ allSql = odpsSchemaUtils.getAllSql(tn, "winhc_ng", "ads", registerSqlVO.getWhere());
|
|
|
+ }
|
|
|
+ Assert.isTrue(StringUtils.isNotEmpty(allSql), "注册失败!");
|
|
|
+
|
|
|
String json = registerSqlVO.getColumns().stream().map(r -> "\"" + r + "\"," + r).collect(Collectors.joining(","));
|
|
|
Integer partitionNum = registerSqlVO.getPartitionNum();
|
|
|
String registerBy = registerSqlVO.getRegisterBy();
|
|
|
|
|
|
- checkColumns(registerSqlVO.getColumns(), tn);
|
|
|
-
|
|
|
- String allSql = odpsSchemaUtils.getAllSql(tn, "winhc_ng", "ads", registerSqlVO.getWhere());
|
|
|
-
|
|
|
+ String finalAllSql = allSql;
|
|
|
Map<String, String> map = new HashMap<String, String>(12) {
|
|
|
{
|
|
|
put("maps", json);
|
|
|
put("partitionNum", partitionNum + "");
|
|
|
- put("allTab", allSql);
|
|
|
+ put("allTab", finalAllSql);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
List<SortVO> sort = registerSqlVO.getSort();
|
|
|
String orderBy = "";
|
|
|
- if (!sort.isEmpty()) {
|
|
|
+ if (sort != null && !sort.isEmpty()) {
|
|
|
orderBy = sort.stream().map(r -> {
|
|
|
if (r.getAse()) {
|
|
|
return r.getField() + " ase";
|
|
@@ -106,6 +112,7 @@ public class OdpsSqlInfoServiceImpl extends ServiceImpl<OdpsSqlInfoMapper, OdpsS
|
|
|
|
|
|
String sql = StrUtil.format(sqlTemp, map);
|
|
|
OdpsSqlInfoVO odpsSqlInfoVO = OdpsSqlInfoVO.builder()
|
|
|
+ .id(registerSqlVO.getId())
|
|
|
.sql(sql)
|
|
|
.outputTab("out_pull_spider_data")
|
|
|
.createBy(registerBy)
|