From defa77d51bddca5b9b1e37128e6b69935b66b15d Mon Sep 17 00:00:00 2001 From: MactavishCui Date: Sat, 2 Nov 2024 23:02:00 +0800 Subject: [PATCH] code style optimization --- .../main/java/org/dinky/data/dto/TaskDTO.java | 8 +-- .../main/java/org/dinky/parser/SqlType.java | 4 +- .../mock/sink/MockDynamicTableSink.java | 24 +++++-- .../sink/MockDynamicTableSinkFactory.java | 30 ++++++-- .../connector/mock/sink/MockSinkFunction.java | 28 ++++++-- .../dinky/data/result/MockResultBuilder.java | 68 ++++++++++++++----- .../org/dinky/data/result/MockSinkResult.java | 32 ++++++--- .../java/org/dinky/explainer/Explainer.java | 44 ++++++++---- .../mock/MockStatementExplainer.java | 45 +++++++++--- .../dinky/job/builder/JobTransBuilder.java | 13 ++-- .../MockStatementExplainerTest.java | 39 ++++++++--- 11 files changed, 251 insertions(+), 84 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java b/dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java index 10bb9734f8..213af7fd5d 100644 --- a/dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java +++ b/dinky-admin/src/main/java/org/dinky/data/dto/TaskDTO.java @@ -209,10 +209,10 @@ public class TaskDTO extends AbstractStatementDTO { private boolean useAutoCancel = true; @ApiModelProperty( - value = "Flag indicating whether to mock sink function", - dataType = "boolean", - example = "true", - notes = "Flag indicating whether to mock sink function") + value = "Flag indicating whether to mock sink function", + dataType = "boolean", + example = "true", + notes = "Flag indicating whether to mock sink function") private boolean mockSinkFunction = true; @ApiModelProperty(value = "Session", dataType = "String", example = "session_id", notes = "The session identifier") diff --git a/dinky-client/dinky-client-base/src/main/java/org/dinky/parser/SqlType.java b/dinky-client/dinky-client-base/src/main/java/org/dinky/parser/SqlType.java index dfd344d261..c3053cf7eb 100644 --- a/dinky-client/dinky-client-base/src/main/java/org/dinky/parser/SqlType.java +++ b/dinky-client/dinky-client-base/src/main/java/org/dinky/parser/SqlType.java @@ -19,11 +19,11 @@ package org.dinky.parser; -import com.google.common.collect.Lists; - import java.util.List; import java.util.regex.Pattern; +import com.google.common.collect.Lists; + /** * SqlType * diff --git a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSink.java b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSink.java index 8b0bbab418..85a55ec650 100644 --- a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSink.java +++ b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSink.java @@ -1,5 +1,23 @@ -package org.dinky.connector.mock.sink; +/* + * + * 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.connector.mock.sink; import org.apache.flink.table.connector.ChangelogMode; import org.apache.flink.table.connector.sink.DynamicTableSink; @@ -11,9 +29,7 @@ public class MockDynamicTableSink implements DynamicTableSink { private final String tableName; private final RowType rowType; - public MockDynamicTableSink( - String tableName, - RowType rowType) { + public MockDynamicTableSink(String tableName, RowType rowType) { this.tableName = tableName; this.rowType = rowType; } diff --git a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSinkFactory.java b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSinkFactory.java index c79f04e176..f157ef0957 100644 --- a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSinkFactory.java +++ b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockDynamicTableSinkFactory.java @@ -1,5 +1,26 @@ +/* + * + * 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.connector.mock.sink; +import static org.apache.flink.configuration.ConfigOptions.key; + import org.apache.flink.configuration.ConfigOption; import org.apache.flink.table.connector.sink.DynamicTableSink; import org.apache.flink.table.factories.DynamicTableSinkFactory; @@ -8,8 +29,6 @@ import java.util.Collections; import java.util.Set; -import static org.apache.flink.configuration.ConfigOptions.key; - public class MockDynamicTableSinkFactory implements DynamicTableSinkFactory { public static final String IDENTIFIER = "dinky-mock"; public static final ConfigOption MOCK_IDENTIFIER = key("mock-identifier") @@ -19,8 +38,11 @@ public class MockDynamicTableSinkFactory implements DynamicTableSinkFactory { @Override public DynamicTableSink createDynamicTableSink(Context context) { - return new MockDynamicTableSink(context.getObjectIdentifier().asSummaryString(), - (RowType) context.getCatalogTable().getResolvedSchema().toPhysicalRowDataType().getLogicalType()); + return new MockDynamicTableSink( + context.getObjectIdentifier().asSummaryString(), (RowType) context.getCatalogTable() + .getResolvedSchema() + .toPhysicalRowDataType() + .getLogicalType()); } @Override diff --git a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockSinkFunction.java b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockSinkFunction.java index 172d279386..2bb1ecc33d 100644 --- a/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockSinkFunction.java +++ b/dinky-core/src/main/java/org/dinky/connector/mock/sink/MockSinkFunction.java @@ -1,3 +1,22 @@ +/* + * + * 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.connector.mock.sink; import org.apache.flink.api.common.accumulators.SerializedListAccumulator; @@ -15,12 +34,11 @@ public class MockSinkFunction extends RichSinkFunction { private final RowType rowType; private final String tableIdentifier; - // when columns is in VARCHAR or STRING type, rowData will be generated to BinaryStringData, which is not serialized, as a result, SerializedListAccumulator is used here + // when columns is in VARCHAR or STRING type, rowData will be generated to BinaryStringData, which is not + // serialized, as a result, SerializedListAccumulator is used here private final SerializedListAccumulator> rowDataList; - public MockSinkFunction( - String tableName, - RowType rowType) { + public MockSinkFunction(String tableName, RowType rowType) { this.rowType = rowType; this.tableIdentifier = tableName; this.rowDataList = new SerializedListAccumulator<>(); @@ -42,4 +60,4 @@ public void invoke(RowData rowData, Context context) throws Exception { } rowDataList.add(rowDataMap, new MapSerializer<>(new StringSerializer(), new StringSerializer())); } -} \ No newline at end of file +} diff --git a/dinky-core/src/main/java/org/dinky/data/result/MockResultBuilder.java b/dinky-core/src/main/java/org/dinky/data/result/MockResultBuilder.java index 48c21bcaa1..0b5ec2885a 100644 --- a/dinky-core/src/main/java/org/dinky/data/result/MockResultBuilder.java +++ b/dinky-core/src/main/java/org/dinky/data/result/MockResultBuilder.java @@ -1,31 +1,57 @@ +/* + * + * 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.data.result; -import alluxio.shaded.client.com.google.common.collect.Lists; -import cn.hutool.core.collection.ListUtil; -import lombok.extern.slf4j.Slf4j; +import org.dinky.assertion.Asserts; +import org.dinky.job.JobHandler; +import org.dinky.utils.JsonUtils; + import org.apache.flink.api.common.typeutils.base.MapSerializer; import org.apache.flink.api.common.typeutils.base.StringSerializer; import org.apache.flink.core.execution.JobClient; import org.apache.flink.core.memory.DataInputViewStreamWrapper; import org.apache.flink.table.api.TableResult; import org.apache.flink.table.catalog.ResolvedSchema; -import org.dinky.assertion.Asserts; -import org.dinky.job.JobHandler; -import org.dinky.utils.JsonUtils; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; -@Slf4j +import alluxio.shaded.client.com.google.common.collect.Lists; +import cn.hutool.core.collection.ListUtil; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class MockResultBuilder extends AbstractResultBuilder implements ResultBuilder { private final Integer maxRowNum; private final boolean isAutoCancel; private final String MOCK_RESULT_TABLE_IDENTIFIER = "dinkySinkResultTableIdentifier"; private final String MOCK_RESULT_COLUMN_IDENTIFIER = "dinkySinkResultColumnIdentifier"; - public MockResultBuilder(String id, Integer maxRowNum, boolean isAutoCancel) { this.id = id; this.maxRowNum = maxRowNum; @@ -45,7 +71,8 @@ public IResult getResult(TableResult tableResult) { if (tableResult.getJobClient().isPresent()) { while (!isAllSinkFinished(maxRowNum, rowDataMap, tableIdentifierList)) { try { - Map accumulatorMap = jobClient.getAccumulators().get(); + Map accumulatorMap = + jobClient.getAccumulators().get(); for (String tableIdentifier : tableIdentifierList) { Object accumulatorObject = accumulatorMap.get(tableIdentifier); if (accumulatorObject instanceof List) { @@ -54,7 +81,8 @@ public IResult getResult(TableResult tableResult) { // deserialize data from accumulator Map deserialize = deserializeObjFromBytes((byte[]) obj); // update row data map - List> rowDataList = rowDataMap.getOrDefault(tableIdentifier, new ArrayList<>()); + List> rowDataList = + rowDataMap.getOrDefault(tableIdentifier, new ArrayList<>()); rowDataList.add(deserialize); rowDataMap.put(tableIdentifier, ListUtil.sub(rowDataList, 0, maxRowNum)); } @@ -85,8 +113,10 @@ public IResult getResultWithPersistence(TableResult tableResult, JobHandler jobH } MockSinkResult mockSinkResult = (MockSinkResult) getResult(tableResult); // MockSinkResult -> SelectResult - SelectResult selectResult = - new SelectResult(id, convertSinkRowData2SelectRowData(mockSinkResult.getTableRowData()), generateMockResultColumns(mockSinkResult.getTableRowData())); + SelectResult selectResult = new SelectResult( + id, + convertSinkRowData2SelectRowData(mockSinkResult.getTableRowData()), + generateMockResultColumns(mockSinkResult.getTableRowData())); selectResult.setMockSinkResult(true); selectResult.setDestroyed(Boolean.TRUE); try { @@ -104,7 +134,8 @@ public IResult getResultWithPersistence(TableResult tableResult, JobHandler jobH * @param tableRowData row data of {@link MockSinkResult} * @return row data of {@link SelectResult} */ - private List> convertSinkRowData2SelectRowData(Map>> tableRowData) { + private List> convertSinkRowData2SelectRowData( + Map>> tableRowData) { List> resultRowData = new ArrayList<>(); for (Map.Entry>> entry : tableRowData.entrySet()) { String tableIdentifier = entry.getKey(); @@ -129,7 +160,8 @@ private List> convertSinkRowData2SelectRowData(Map>> rowData, List tableIdentifierList) { + private boolean isAllSinkFinished( + int maxRowNum, Map>> rowData, List tableIdentifierList) { if (tableIdentifierList.size() > rowData.size()) { return false; } @@ -162,8 +194,8 @@ private LinkedHashSet generateMockResultColumns(Map deserializeObjFromBytes(byte[] byteArr) throws IOException { - MapSerializer mapSerializer = new MapSerializer<>(new StringSerializer(), new StringSerializer()); + MapSerializer mapSerializer = + new MapSerializer<>(new StringSerializer(), new StringSerializer()); return mapSerializer.deserialize(new DataInputViewStreamWrapper(new ByteArrayInputStream(byteArr))); } - -} \ No newline at end of file +} diff --git a/dinky-core/src/main/java/org/dinky/data/result/MockSinkResult.java b/dinky-core/src/main/java/org/dinky/data/result/MockSinkResult.java index 81ea533a02..164bf2a2cc 100644 --- a/dinky-core/src/main/java/org/dinky/data/result/MockSinkResult.java +++ b/dinky-core/src/main/java/org/dinky/data/result/MockSinkResult.java @@ -1,14 +1,33 @@ +/* + * + * 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.data.result; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Map; + import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import java.time.LocalDateTime; -import java.util.List; -import java.util.Map; - @Slf4j @Setter @Getter @@ -20,9 +39,7 @@ public class MockSinkResult extends AbstractResult implements IResult { private boolean truncationFlag = false; private boolean isDestroyed; - public MockSinkResult( - String taskId, - Map>> tableRowData) { + public MockSinkResult(String taskId, Map>> tableRowData) { this.taskId = taskId; this.tableRowData = tableRowData; } @@ -46,5 +63,4 @@ public static MockSinkResult buildFailed() { public String getJobId() { return this.taskId; } - } diff --git a/dinky-core/src/main/java/org/dinky/explainer/Explainer.java b/dinky-core/src/main/java/org/dinky/explainer/Explainer.java index 92df96bf30..febba23cb9 100644 --- a/dinky-core/src/main/java/org/dinky/explainer/Explainer.java +++ b/dinky-core/src/main/java/org/dinky/explainer/Explainer.java @@ -19,18 +19,6 @@ package org.dinky.explainer; -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.text.StrBuilder; -import cn.hutool.core.text.StrFormatter; -import cn.hutool.core.util.StrUtil; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.Sets; -import lombok.extern.slf4j.Slf4j; -import org.apache.flink.api.dag.Pipeline; -import org.apache.flink.configuration.Configuration; -import org.apache.flink.core.fs.FileSystem; -import org.apache.flink.runtime.rest.messages.JobPlanInfo; import org.dinky.assertion.Asserts; import org.dinky.data.enums.GatewayType; import org.dinky.data.exception.DinkyException; @@ -57,13 +45,38 @@ import org.dinky.trans.parse.AddJarSqlParseStrategy; import org.dinky.trans.parse.ExecuteJarParseStrategy; import org.dinky.trans.parse.SetSqlParseStrategy; -import org.dinky.utils.*; +import org.dinky.utils.DinkyClassLoaderUtil; +import org.dinky.utils.FlinkStreamEnvironmentUtil; +import org.dinky.utils.IpUtil; +import org.dinky.utils.LogUtil; +import org.dinky.utils.SqlUtil; +import org.dinky.utils.URLUtils; + +import org.apache.flink.api.dag.Pipeline; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.core.fs.FileSystem; +import org.apache.flink.runtime.rest.messages.JobPlanInfo; import java.net.URL; import java.time.LocalDateTime; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.collect.Sets; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.text.StrBuilder; +import cn.hutool.core.text.StrFormatter; +import cn.hutool.core.util.StrUtil; +import lombok.extern.slf4j.Slf4j; + /** * Explainer * @@ -170,7 +183,8 @@ public JobParam pretreatStatements(String[] statements) { statementList.add(statement); } } - JobParam jobParam = new JobParam(statementList, ddl, trans, execute, CollUtil.removeNull(udfList), parsedSql.toString()); + JobParam jobParam = + new JobParam(statementList, ddl, trans, execute, CollUtil.removeNull(udfList), parsedSql.toString()); if (jobManager.getConfig().isMockSinkFunction()) { MockStatementExplainer.jobParamMock(jobParam); } diff --git a/dinky-core/src/main/java/org/dinky/explainer/mock/MockStatementExplainer.java b/dinky-core/src/main/java/org/dinky/explainer/mock/MockStatementExplainer.java index c5f502dfc2..9b13be7542 100644 --- a/dinky-core/src/main/java/org/dinky/explainer/mock/MockStatementExplainer.java +++ b/dinky-core/src/main/java/org/dinky/explainer/mock/MockStatementExplainer.java @@ -1,8 +1,24 @@ +/* + * + * 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.explainer.mock; -import lombok.extern.slf4j.Slf4j; -import org.apache.calcite.sql.SqlInsert; -import org.apache.calcite.sql.parser.SqlParser; import org.dinky.assertion.Asserts; import org.dinky.connector.mock.sink.MockDynamicTableSinkFactory; import org.dinky.job.JobParam; @@ -10,16 +26,26 @@ import org.dinky.parser.SqlType; import org.dinky.utils.JsonUtils; +import org.apache.calcite.sql.SqlInsert; +import org.apache.calcite.sql.parser.SqlParser; + import java.text.MessageFormat; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import lombok.extern.slf4j.Slf4j; + @Slf4j public class MockStatementExplainer { - - public static final String PATTERN_STR = "CREATE\\s+TABLE\\s+(\\w+)\\s*\\(\\s*([\\s\\S]*?)\\s*\\)\\s*WITH\\s*\\(\\s*([\\s\\S]*?)\\s*\\)"; + public static final String PATTERN_STR = + "CREATE\\s+TABLE\\s+(\\w+)\\s*\\(\\s*([\\s\\S]*?)\\s*\\)\\s*WITH\\s*\\(\\s*([\\s\\S]*?)\\s*\\)"; public static final Pattern PATTERN = Pattern.compile(PATTERN_STR, Pattern.CASE_INSENSITIVE); public static final String MOCK_SQL_TEMPLATE = "CREATE TABLE {0} ({1}) WITH ({2})"; @@ -35,7 +61,8 @@ public static void jobParamMock(JobParam jobParam) { List mockedDdl = new ArrayList<>(); for (StatementParam ddl : jobParam.getDdl()) { // table name check - String tableName = getDdlTableName(ddl.getValue().replaceAll("\\n", " ").replaceAll(" +", " ")); + String tableName = + getDdlTableName(ddl.getValue().replaceAll("\\n", " ").replaceAll(" +", " ")); // mock connector if (Asserts.isNotNull(tableName) && tablesNeedMock.contains(tableName.toUpperCase())) { mockedDdl.add(new StatementParam(getSinkMockDdlStatement(ddl.getValue()), SqlType.CREATE)); @@ -58,7 +85,8 @@ private static Set getMockedTableNames(List transStateme for (StatementParam statement : transStatements) { if (statement.getType().equals(SqlType.INSERT)) { try { - SqlInsert sqlInsert = (SqlInsert) SqlParser.create(statement.getValue()).parseQuery(); + SqlInsert sqlInsert = + (SqlInsert) SqlParser.create(statement.getValue()).parseQuery(); insertTables.add(sqlInsert.getTargetTable().toString()); } catch (Exception e) { log.error("Statement parse error, statement: {}", statement.getValue()); @@ -128,5 +156,4 @@ private static Map parseWithClause(String withClause) { } return options; } - } diff --git a/dinky-core/src/main/java/org/dinky/job/builder/JobTransBuilder.java b/dinky-core/src/main/java/org/dinky/job/builder/JobTransBuilder.java index 4ee4cefc5d..f750c039f2 100644 --- a/dinky-core/src/main/java/org/dinky/job/builder/JobTransBuilder.java +++ b/dinky-core/src/main/java/org/dinky/job/builder/JobTransBuilder.java @@ -19,9 +19,6 @@ package org.dinky.job.builder; -import org.apache.flink.runtime.jobgraph.JobGraph; -import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings; -import org.apache.flink.table.api.TableResult; import org.dinky.assertion.Asserts; import org.dinky.constant.FlinkSQLConstant; import org.dinky.data.enums.GatewayType; @@ -33,10 +30,18 @@ import org.dinky.gateway.result.GatewayResult; import org.dinky.interceptor.FlinkInterceptor; import org.dinky.interceptor.FlinkInterceptorResult; -import org.dinky.job.*; +import org.dinky.job.Job; +import org.dinky.job.JobBuilder; +import org.dinky.job.JobConfig; +import org.dinky.job.JobManager; +import org.dinky.job.StatementParam; import org.dinky.parser.SqlType; import org.dinky.utils.URLUtils; +import org.apache.flink.runtime.jobgraph.JobGraph; +import org.apache.flink.runtime.jobgraph.SavepointRestoreSettings; +import org.apache.flink.table.api.TableResult; + import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/dinky-core/src/test/java/org/dinky/explainermock/MockStatementExplainerTest.java b/dinky-core/src/test/java/org/dinky/explainermock/MockStatementExplainerTest.java index 7198711b36..8025bf8ba7 100644 --- a/dinky-core/src/test/java/org/dinky/explainermock/MockStatementExplainerTest.java +++ b/dinky-core/src/test/java/org/dinky/explainermock/MockStatementExplainerTest.java @@ -1,21 +1,39 @@ -package org.dinky.explainermock; +/* + * + * 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. + * + */ -import org.junit.Test; +package org.dinky.explainermock; import java.util.regex.Matcher; import java.util.regex.Pattern; public class MockStatementExplainerTest { - public static final String PATTERN_STR = "CREATE\\s+TABLE\\s+(\\w+)\\s*\\(\\s*([\\s\\S]*?)\\s*\\)\\s*WITH\\s*\\(\\s*([\\s\\S]*?)\\s*\\)"; + public static final String PATTERN_STR = + "CREATE\\s+TABLE\\s+(\\w+)\\s*\\(\\s*([\\s\\S]*?)\\s*\\)\\s*WITH\\s*\\(\\s*([\\s\\S]*?)\\s*\\)"; public static final Pattern PATTERN = Pattern.compile(PATTERN_STR, Pattern.CASE_INSENSITIVE); + public static void main(String[] args) { - String sql = "CREATE " + - " TABLE skuSink (" + - "sku_id BIGINT," + - "sku_name STRING" + - ")" + - "\nWITH ( " + - "\n'connector' = 'blackhole')"; + String sql = "CREATE " + " TABLE skuSink (" + + "sku_id BIGINT," + + "sku_name STRING" + + ")" + + "\nWITH ( " + + "\n'connector' = 'blackhole')"; Matcher matcher = PATTERN.matcher(sql); System.out.println(matcher.find()); @@ -23,5 +41,4 @@ public static void main(String[] args) { System.out.println(matcher.group(2)); System.out.println(matcher.group(3)); } - }