Unverified Commit 43bd8265 authored by Licho's avatar Licho Committed by GitHub

fix: CTAS not execute (#2647)

* fix: CTAS not execute Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> * Spotless Apply --------- Signed-off-by: 's avatarlicho <lecho.sun@gmail.com> Co-authored-by: 's avatarleechor <leechor@users.noreply.github.com>
parent 7712e433
......@@ -66,8 +66,6 @@ import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.QueryOperation;
import org.apache.flink.table.operations.command.ResetOperation;
import org.apache.flink.table.operations.command.SetOperation;
import org.apache.flink.table.operations.ddl.CreateTableASOperation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;
import org.apache.flink.table.planner.delegation.DefaultExecutor;
import org.apache.flink.table.typeutils.FieldInfoUtils;
import org.apache.flink.types.Row;
......@@ -376,16 +374,6 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
createTemporaryView(s, fromChangelogStream(dataStream));
}
@Override
public void executeCTAS(Operation operation) {
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableASOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableASOperation.getCreateTableOperation();
executeInternal(createTableOperation);
getPlanner().translate(CollUtil.newArrayList(createTableASOperation.getInsertOperation()));
}
}
@Override
public <T> void createTemporaryView(String path, DataStream<T> dataStream, Expression... fields) {
createTemporaryView(path, fromDataStream(dataStream, fields));
......
......@@ -59,11 +59,8 @@ import org.apache.flink.table.operations.ExplainOperation;
import org.apache.flink.table.operations.ModifyOperation;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.QueryOperation;
import org.apache.flink.table.operations.SinkModifyOperation;
import org.apache.flink.table.operations.command.ResetOperation;
import org.apache.flink.table.operations.command.SetOperation;
import org.apache.flink.table.operations.ddl.CreateTableASOperation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;
import org.apache.flink.types.Row;
import java.io.File;
......@@ -348,17 +345,6 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
createTemporaryView(s, fromChangelogStream(dataStream));
}
@Override
public void executeCTAS(Operation operation) {
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableASOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableASOperation.getCreateTableOperation();
executeInternal(createTableOperation);
SinkModifyOperation sinkModifyOperation = createTableASOperation.toSinkModifyOperation(getCatalogManager());
getPlanner().translate(CollUtil.newArrayList(sinkModifyOperation));
}
}
@Override
public <T> void createTemporaryView(String path, DataStream<T> dataStream, Expression... fields) {
createTemporaryView(path, fromDataStream(dataStream, fields));
......
......@@ -41,15 +41,12 @@ import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.ExplainDetail;
import org.apache.flink.table.api.TableException;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.operations.CreateTableASOperation;
import org.apache.flink.table.operations.ExplainOperation;
import org.apache.flink.table.operations.ModifyOperation;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.QueryOperation;
import org.apache.flink.table.operations.SinkModifyOperation;
import org.apache.flink.table.operations.command.ResetOperation;
import org.apache.flink.table.operations.command.SetOperation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;
import org.apache.flink.types.Row;
import java.util.ArrayList;
......@@ -64,8 +61,6 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.hutool.core.collection.CollUtil;
/**
* CustomTableEnvironmentImpl
*
......@@ -165,14 +160,7 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
throw new TableException("Only single statement is supported.");
}
Operation operation = operations.get(0);
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableAsOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableAsOperation.getCreateTableOperation();
executeInternal(createTableOperation);
SinkModifyOperation sinkModifyOperation =
createTableAsOperation.toSinkModifyOperation(getCatalogManager());
getPlanner().translate(CollUtil.newArrayList(sinkModifyOperation));
} else if (operation instanceof ModifyOperation) {
if (operation instanceof ModifyOperation) {
modifyOperations.add((ModifyOperation) operation);
} else {
throw new TableException("Only insert statement is supported now.");
......@@ -265,15 +253,4 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
public <T> void createTemporaryView(String s, DataStream<Row> dataStream, List<String> columnNameList) {
createTemporaryView(s, fromChangelogStream(dataStream));
}
@Override
public void executeCTAS(Operation operation) {
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableASOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableASOperation.getCreateTableOperation();
executeInternal(createTableOperation);
SinkModifyOperation sinkModifyOperation = createTableASOperation.toSinkModifyOperation(getCatalogManager());
getPlanner().translate(CollUtil.newArrayList(sinkModifyOperation));
}
}
}
......@@ -40,15 +40,12 @@ import org.apache.flink.table.api.ExplainDetail;
import org.apache.flink.table.api.ExplainFormat;
import org.apache.flink.table.api.TableException;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.operations.CreateTableASOperation;
import org.apache.flink.table.operations.ExplainOperation;
import org.apache.flink.table.operations.ModifyOperation;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.QueryOperation;
import org.apache.flink.table.operations.SinkModifyOperation;
import org.apache.flink.table.operations.command.ResetOperation;
import org.apache.flink.table.operations.command.SetOperation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;
import org.apache.flink.types.Row;
import java.util.ArrayList;
......@@ -65,8 +62,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.hutool.core.collection.CollUtil;
/**
* CustomTableEnvironmentImpl
*
......@@ -167,9 +162,7 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
throw new TableException("Only single statement is supported.");
}
Operation operation = operations.get(0);
if (operation instanceof CreateTableASOperation) {
executeCTAS(operation);
} else if (operation instanceof ModifyOperation) {
if (operation instanceof ModifyOperation) {
modifyOperations.add((ModifyOperation) operation);
} else {
throw new TableException("Only insert statement is supported now.");
......@@ -264,15 +257,4 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
public <T> void createTemporaryView(String s, DataStream<Row> dataStream, List<String> columnNameList) {
createTemporaryView(s, fromChangelogStream(dataStream));
}
@Override
public void executeCTAS(Operation operation) {
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableASOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableASOperation.getCreateTableOperation();
executeInternal(createTableOperation);
SinkModifyOperation sinkModifyOperation = createTableASOperation.toSinkModifyOperation(getCatalogManager());
getPlanner().translate(CollUtil.newArrayList(sinkModifyOperation));
}
}
}
......@@ -42,15 +42,12 @@ import org.apache.flink.table.api.TableException;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.api.internal.TableEnvironmentImpl;
import org.apache.flink.table.catalog.CatalogDescriptor;
import org.apache.flink.table.operations.CreateTableASOperation;
import org.apache.flink.table.operations.ExplainOperation;
import org.apache.flink.table.operations.ModifyOperation;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.table.operations.QueryOperation;
import org.apache.flink.table.operations.SinkModifyOperation;
import org.apache.flink.table.operations.command.ResetOperation;
import org.apache.flink.table.operations.command.SetOperation;
import org.apache.flink.table.operations.ddl.CreateTableOperation;
import org.apache.flink.types.Row;
import java.util.ArrayList;
......@@ -67,8 +64,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import cn.hutool.core.collection.CollUtil;
/**
* CustomTableEnvironmentImpl
*
......@@ -168,9 +163,7 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
throw new TableException("Only single statement is supported.");
}
Operation operation = operations.get(0);
if (operation instanceof CreateTableASOperation) {
executeCTAS(operation);
} else if (operation instanceof ModifyOperation) {
if (operation instanceof ModifyOperation) {
modifyOperations.add((ModifyOperation) operation);
} else {
throw new TableException("Only insert statement is supported now.");
......@@ -266,17 +259,6 @@ public class CustomTableEnvironmentImpl extends AbstractCustomTableEnvironment {
createTemporaryView(s, fromChangelogStream(dataStream));
}
@Override
public void executeCTAS(Operation operation) {
if (operation instanceof CreateTableASOperation) {
CreateTableASOperation createTableASOperation = (CreateTableASOperation) operation;
CreateTableOperation createTableOperation = createTableASOperation.getCreateTableOperation();
executeInternal(createTableOperation);
SinkModifyOperation sinkModifyOperation = createTableASOperation.toSinkModifyOperation(getCatalogManager());
getPlanner().translate(CollUtil.newArrayList(sinkModifyOperation));
}
}
@Override
public void createCatalog(String catalogName, CatalogDescriptor catalogDescriptor) {
getCatalogManager().createCatalog(catalogName, catalogDescriptor);
......
......@@ -33,7 +33,6 @@ import org.apache.flink.table.api.ExplainDetail;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.table.api.internal.TableEnvironmentInternal;
import org.apache.flink.table.delegation.Planner;
import org.apache.flink.table.operations.Operation;
import org.apache.flink.types.Row;
import java.io.File;
......@@ -83,8 +82,6 @@ public interface CustomTableEnvironment
<T> void createTemporaryView(String s, DataStream<Row> dataStream, List<String> columnNameList);
void executeCTAS(Operation operation);
default void addJar(File... jarPath) {
Configuration configuration = this.getRootConfiguration();
List<String> pathList =
......
......@@ -230,35 +230,8 @@ public class Explainer {
if (useStatementSet) {
List<String> inserts = new ArrayList<>();
for (StatementParam item : jobParam.getTrans()) {
if (item.getType().equals(SqlType.INSERT)) {
if (item.getType().equals(SqlType.INSERT) || item.getType().equals(SqlType.CTAS)) {
inserts.add(item.getValue());
} else if (item.getType().equals(SqlType.CTAS)) {
SqlExplainResult record = new SqlExplainResult();
try {
record.setParseTrue(true);
record.setExplainTrue(true);
record.setSql(item.getValue());
executor.getCustomTableEnvironment()
.getParser()
.parse(item.getValue())
.forEach(x -> {
executor.getCustomTableEnvironment().executeCTAS(x);
});
} catch (Exception e) {
String error = LogUtil.getError(e);
record.setError(error);
record.setParseTrue(false);
record.setExplainTrue(false);
correct = false;
log.error(error);
break;
} finally {
record.setType("Modify DML");
record.setExplainTime(LocalDateTime.now());
record.setIndex(index);
sqlExplainRecords.add(record);
}
}
}
if (!inserts.isEmpty()) {
......
......@@ -97,24 +97,12 @@ public class JobTransBuilder extends JobBuilder {
? jobParam.getTrans()
: Collections.singletonList(jobParam.getTrans().get(0));
for (StatementParam item : statementParams) {
if (!useGateway && !item.getType().equals(SqlType.INSERT)) {
handleNonInsertType(item);
continue;
}
inserts.add(item.getValue());
}
return inserts;
}
private void handleNonInsertType(StatementParam item) {
if (item.getType().equals(SqlType.CTAS)) {
executor.getCustomTableEnvironment()
.getParser()
.parse(item.getValue())
.forEach(executor.getCustomTableEnvironment()::executeCTAS);
}
}
private void processWithGateway(List<String> inserts) throws Exception {
jobManager.setCurrentSql(String.join(sqlSeparator, inserts));
GatewayResult gatewayResult = submitByGateway(inserts);
......
......@@ -43,19 +43,19 @@ const GlobalHeaderRight: React.FC = () => {
useEffect(() => {
setLangCache(language);
(async () =>
await setInitialState((initialStateType:any) => ({
await setInitialState((initialStateType: any) => ({
...initialStateType,
locale: language,
settings: {
...initialStateType?.settings,
navTheme: theme,
token:{
token: {
...initialStateType?.settings?.token,
sider: {
...initialStateType?.settings?.token?.sider,
colorMenuBackground: theme === THEME.dark ? '#000' : '#fff',
colorMenuBackground: theme === THEME.dark ? '#000' : '#fff'
}
},
}
}
})))();
}, [theme, language]);
......
......@@ -136,7 +136,7 @@ const DataStudio = (props: any) => {
const centerContentHeight = size.contentHeight - newBottomHeight;
updateCenterContentHeight(centerContentHeight);
updateToolContentHeight(centerContentHeight - VIEW.leftMargin);
}, [activeKey,panes]);
}, [activeKey, panes]);
useEffect(() => {
loadData();
......
......@@ -512,12 +512,12 @@ const Model: ModelType = {
) {
centerContentHeight = state.centerContentHeight;
toolContentHeight = state.toolContentHeight;
}
else {
if (state.centerContentHeight>state.bottomContainer.height){
centerContentHeight = state.centerContentHeight - (state.bottomContainer.height as number);
} else {
if (state.centerContentHeight > state.bottomContainer.height) {
centerContentHeight =
state.centerContentHeight - (state.bottomContainer.height as number);
toolContentHeight = state.toolContentHeight - (state.bottomContainer.height as number);
}else {
} else {
centerContentHeight = state.centerContentHeight;
toolContentHeight = state.toolContentHeight;
}
......@@ -677,7 +677,12 @@ const Model: ModelType = {
for (const [index, pane] of panes.entries()) {
if (pane.key === needCloseKey) {
const nextPane = panes[(index + 1) % panes.length];
const height = document.documentElement.clientHeight - VIEW.headerHeight - VIEW.headerNavHeight - VIEW.footerHeight - VIEW.otherHeight;
const height =
document.documentElement.clientHeight -
VIEW.headerHeight -
VIEW.headerNavHeight -
VIEW.footerHeight -
VIEW.otherHeight;
return {
...state,
tabs: {
......@@ -692,8 +697,9 @@ const Model: ModelType = {
...state.footContainer,
...getFooterValue(panes, nextPane.key)
},
toolContentHeight: panes.length < 2? height-VIEW.leftMargin : state.toolContentHeight,
centerContentHeight: panes.length < 2? height : state.toolContentHeight,
toolContentHeight:
panes.length < 2 ? height - VIEW.leftMargin : state.toolContentHeight,
centerContentHeight: panes.length < 2 ? height : state.toolContentHeight
};
}
}
......
......@@ -17,6 +17,7 @@
*
*/
import { CreateBtn } from '@/components/CallBackButton/CreateBtn';
import { EditBtn } from '@/components/CallBackButton/EditBtn';
import { NormalDeleteBtn } from '@/components/CallBackButton/NormalDeleteBtn';
import { Authorized } from '@/hooks/useAccess';
......@@ -29,12 +30,11 @@ import { AlertTemplateState } from '@/types/RegCenter/state';
import { l } from '@/utils/intl';
import { useRequest } from '@@/exports';
import { PlusOutlined } from '@ant-design/icons';
import { ProList } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout';
import {Button, Card, Input, List, Modal} from 'antd';
import React, { useState } from 'react';
import { Button, Card, List, Modal } from 'antd';
import { useState } from 'react';
import Markdown from 'react-markdown';
import {ProList} from "@ant-design/pro-components";
import {CreateBtn} from "@/components/CallBackButton/CreateBtn";
export default () => {
const [alertTemplateState, setAlertTemplateState] =
......@@ -115,10 +115,12 @@ export default () => {
<Authorized key='create' path='/registration/alert/template/add'>
<CreateBtn
key={'CreateAlertTemplateBtn'}
onClick={() => setAlertTemplateState((prevState) => ({
...prevState,
addedOpen: true
}))}
onClick={() =>
setAlertTemplateState((prevState) => ({
...prevState,
addedOpen: true
}))
}
/>
</Authorized>
];
......
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