Unverified Commit 543bb753 authored by Licho's avatar Licho Committed by GitHub

feat: implement operator with SPI (#2845)

* feat: implement operatore with SPI * chore: remove used class
parent 422fa9e4
......@@ -122,7 +122,7 @@ public class ClearJobHistoryHandler {
for (History history : historyList) {
// Check if the count exceeds the maximum retain count
if (history.getCount() > maxRetainCount) {
List<History> reservedHistorys = historyService
List<History> reservedHistory = historyService
.lambdaQuery()
.eq(History::getTaskId, history.getTaskId())
.orderByDesc(History::getId)
......@@ -137,7 +137,7 @@ public class ClearJobHistoryHandler {
.notIn(
true,
History::getId,
reservedHistorys.stream().map(History::getId).toArray());
reservedHistory.stream().map(History::getId).toArray());
historyService.remove(deleteWrapper);
}
}
......
......@@ -19,27 +19,19 @@
package org.dinky.parser;
import org.dinky.trans.parse.AddJarSqlParseStrategy;
import org.dinky.trans.parse.CreateAggTableSelectSqlParseStrategy;
import org.dinky.trans.parse.CreateTemporalTableFunctionParseStrategy;
import org.dinky.trans.parse.SetSqlParseStrategy;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.planner.parse.ExtendedParseStrategy;
import org.apache.flink.table.planner.parse.ExtendedParser;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
public class DinkyExtendedParser extends ExtendedParser {
public static final DinkyExtendedParser INSTANCE = new DinkyExtendedParser();
public static final List<ExtendedParseStrategy> PARSE_STRATEGIES = Arrays.asList(
AddJarSqlParseStrategy.INSTANCE,
CreateAggTableSelectSqlParseStrategy.INSTANCE,
SetSqlParseStrategy.INSTANCE,
CreateTemporalTableFunctionParseStrategy.INSTANCE);
protected static final List<ExtendedParseStrategy> PARSE_STRATEGIES = loadExtendedStrategies();
@Override
public Optional<Operation> parse(String statement) {
......@@ -50,4 +42,14 @@ public class DinkyExtendedParser extends ExtendedParser {
}
return Optional.empty();
}
private static List<ExtendedParseStrategy> loadExtendedStrategies() {
// load ExtendedParserStrategy class with ServiceLoader
List<ExtendedParseStrategy> parseStrategies = new ArrayList<>();
ServiceLoader<ExtendedParseStrategy> extendedParseStrategies = ServiceLoader.load(ExtendedParseStrategy.class);
for (ExtendedParseStrategy extendedParseStrategy : extendedParseStrategies) {
parseStrategies.add(extendedParseStrategy);
}
return parseStrategies;
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.trans.ddl;
import org.dinky.executor.CustomTableEnvironment;
import org.dinky.trans.AbstractOperation;
import org.dinky.trans.ExtendOperation;
import org.apache.flink.table.api.TableResult;
import java.util.Optional;
public class PrintTableOperation extends AbstractOperation implements ExtendOperation {
public PrintTableOperation() {}
@Override
public Optional<? extends TableResult> execute(CustomTableEnvironment tEnv) {
return Optional.empty();
}
@Override
public String asSummaryString() {
return null;
}
}
......@@ -46,7 +46,7 @@ public class AddJarSqlParseStrategy extends AbstractRegexParseStrategy {
private static final Pattern ADD_JAR_PATTERN = Pattern.compile(ADD_JAR, Pattern.CASE_INSENSITIVE);
public static final AddJarSqlParseStrategy INSTANCE = new AddJarSqlParseStrategy();
protected AddJarSqlParseStrategy() {
public AddJarSqlParseStrategy() {
super(ADD_JAR_PATTERN);
}
......
......@@ -45,7 +45,7 @@ public class CreateTemporalTableFunctionParseStrategy extends AbstractRegexParse
public static final CreateTemporalTableFunctionParseStrategy INSTANCE =
new CreateTemporalTableFunctionParseStrategy();
protected CreateTemporalTableFunctionParseStrategy() {
public CreateTemporalTableFunctionParseStrategy() {
super(PATTERN);
}
......
......@@ -40,7 +40,7 @@ public class ExecuteJarParseStrategy extends AbstractRegexParseStrategy {
private static final Pattern PATTERN = Pattern.compile(PATTERN_STR, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
public static final ExecuteJarParseStrategy INSTANCE = new ExecuteJarParseStrategy();
protected ExecuteJarParseStrategy() {
public ExecuteJarParseStrategy() {
super(PATTERN);
}
......
org.dinky.trans.parse.AddJarSqlParseStrategy
org.dinky.trans.parse.CreateAggTableSelectSqlParseStrategy
org.dinky.trans.parse.CreateTemporalTableFunctionParseStrategy
org.dinky.trans.parse.ExecuteJarParseStrategy
org.dinky.trans.parse.SetSqlParseStrategy
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment