Skip to content

Commit

Permalink
[Fix-2806] [Flink] The job parameters are not effective when the set …
Browse files Browse the repository at this point in the history
…parameters key and value contain single quotes
  • Loading branch information
aiwenmo committed Dec 26, 2023
1 parent c861202 commit 596607d
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public SetSqlParseStrategy() {
public static Map<String, List<String>> getInfo(String statement) {
// SET(\s+(\S+)\s*=(.*))?
List<SqlSegment> segments = new ArrayList<>();
segments.add(new SqlSegment("(set)\\s+(.+)(\\s*=)", "[.]"));
segments.add(new SqlSegment("(=)\\s*(.*)($)", ","));
segments.add(new SqlSegment("(set)\\s+'?([^']+)'?(\\s*=)", "[.]"));
segments.add(new SqlSegment("(=)\\s*'?([^']+)'?($)", ","));
return SqlSegmentUtil.splitSql2Segment(segments, statement);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
*
* 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.junit.Assert;
import org.junit.Test;

/**
* CustomSetOperationTest
*
*/
public class CustomSetOperationTest {

private static final String SET_STATEMENT1 = "set execution.checkpointing.interval = 80000";
private static final String SET_STATEMENT2 = "SET 'execution.checkpointing.interval' = '80000'";
private static final String SET_STATEMENT3 = "SET 'execution.checkpointing.interval = 80000'";

@Test
public void setOperationTest() {
String expectKey = "execution.checkpointing.interval";
String expectValue = "80000";
CustomSetOperation customSetOperation1 = new CustomSetOperation(SET_STATEMENT1);
Assert.assertEquals(expectKey, customSetOperation1.getKey());
Assert.assertEquals(expectValue, customSetOperation1.getValue());
CustomSetOperation customSetOperation2 = new CustomSetOperation(SET_STATEMENT2);
Assert.assertEquals(expectKey, customSetOperation2.getKey());
Assert.assertEquals(expectValue, customSetOperation2.getValue());
CustomSetOperation customSetOperation3 = new CustomSetOperation(SET_STATEMENT3);
Assert.assertEquals(expectKey, customSetOperation3.getKey());
Assert.assertEquals(expectValue, customSetOperation3.getValue());
}
}

0 comments on commit 596607d

Please sign in to comment.