forked from DataLinkDC/dinky
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add operation execute compatible for flink 1.18 (DataLinkDC#2637)
* feat: add operation execute compatible for flink 1.18 Signed-off-by: licho <lecho.sun@gmail.com> * Spotless Apply * Spotless Apply --------- Signed-off-by: licho <lecho.sun@gmail.com> Co-authored-by: leechor <leechor@users.noreply.github.com>
- Loading branch information
Showing
19 changed files
with
267 additions
and
40 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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
dinky-client/dinky-client-1.18/src/main/java/org/dinky/operations/CustomNewParserImpl.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,41 @@ | ||
/* | ||
* | ||
* 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.operations; | ||
|
||
import org.dinky.parser.CustomParserImpl; | ||
|
||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.delegation.Parser; | ||
import org.apache.flink.table.planner.parse.ExtendedParser; | ||
|
||
public class CustomNewParserImpl extends CustomParserImpl { | ||
|
||
private final DinkyParser dinkyParser; | ||
|
||
public CustomNewParserImpl(TableEnvironment tableEnvironment, Parser parser) { | ||
super(parser); | ||
this.dinkyParser = new DinkyParser(tableEnvironment); | ||
} | ||
|
||
@Override | ||
public ExtendedParser getDinkyParser() { | ||
return this.dinkyParser; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...client/dinky-client-1.18/src/main/java/org/dinky/operations/DinkyExecutableOperation.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,51 @@ | ||
/* | ||
* | ||
* 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.operations; | ||
|
||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.api.internal.TableResultInternal; | ||
import org.apache.flink.table.operations.ExecutableOperation; | ||
import org.apache.flink.table.operations.Operation; | ||
|
||
public class DinkyExecutableOperation implements ExecutableOperation { | ||
|
||
private final Operation innerOperation; | ||
private final TableEnvironment tableEnvironment; | ||
|
||
public DinkyExecutableOperation(TableEnvironment tableEnvironment, Operation innerOperation) { | ||
this.tableEnvironment = tableEnvironment; | ||
this.innerOperation = innerOperation; | ||
} | ||
|
||
@Override | ||
public TableResultInternal execute(Context ctx) { | ||
DinkyOperationExecutor operationExecutor = new DinkyOperationExecutor(tableEnvironment, ctx); | ||
return operationExecutor.executeOperation(innerOperation).get(); | ||
} | ||
|
||
public Operation getInnerOperation() { | ||
return innerOperation; | ||
} | ||
|
||
@Override | ||
public String asSummaryString() { | ||
return innerOperation.asSummaryString(); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...y-client/dinky-client-1.18/src/main/java/org/dinky/operations/DinkyOperationExecutor.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,48 @@ | ||
/* | ||
* | ||
* 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.operations; | ||
|
||
import org.dinky.executor.CustomTableEnvironment; | ||
import org.dinky.trans.ExtendOperation; | ||
|
||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.api.internal.TableResultInternal; | ||
import org.apache.flink.table.operations.ExecutableOperation; | ||
import org.apache.flink.table.operations.Operation; | ||
|
||
import java.util.Optional; | ||
|
||
public class DinkyOperationExecutor { | ||
private final ExecutableOperation.Context context; | ||
|
||
private final TableEnvironment tableEnvironment; | ||
|
||
public DinkyOperationExecutor(TableEnvironment tableEnvironment, ExecutableOperation.Context context) { | ||
this.tableEnvironment = tableEnvironment; | ||
this.context = context; | ||
} | ||
|
||
public Optional<TableResultInternal> executeOperation(Operation operation) { | ||
ExtendOperation extendOperation = (ExtendOperation) operation; | ||
return Optional.of((TableResultInternal) extendOperation | ||
.execute((CustomTableEnvironment) tableEnvironment) | ||
.get()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
dinky-client/dinky-client-1.18/src/main/java/org/dinky/operations/DinkyParser.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,46 @@ | ||
/* | ||
* | ||
* 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.operations; | ||
|
||
import org.dinky.parser.DinkyExtendedParser; | ||
|
||
import org.apache.flink.table.api.TableEnvironment; | ||
import org.apache.flink.table.operations.Operation; | ||
import org.apache.flink.table.planner.parse.ExtendedParseStrategy; | ||
|
||
import java.util.Optional; | ||
|
||
public class DinkyParser extends DinkyExtendedParser { | ||
private final TableEnvironment tableEnvironment; | ||
|
||
public DinkyParser(TableEnvironment tableEnvironment) { | ||
this.tableEnvironment = tableEnvironment; | ||
} | ||
|
||
@Override | ||
public Optional<Operation> parse(String statement) { | ||
for (ExtendedParseStrategy strategy : PARSE_STRATEGIES) { | ||
if (strategy.match(statement)) { | ||
return Optional.of(new DinkyExecutableOperation(this.tableEnvironment, strategy.convert(statement))); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
} |
File renamed without changes.
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
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.