-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature][starter] support user define parameter on spark/flink engine #6387
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! There are some problems in your commit. Unit test for project connector-cdc-sqlserver-e2e was failed, please check your commit.
if (variables != null) { | ||
Map<String, String> map = | ||
variables.stream() | ||
.filter(Objects::nonNull) | ||
.map(variable -> variable.split("=", 2)) | ||
.filter(pair -> pair.length == 2F) | ||
.collect(Collectors.toMap(pair -> pair[0], pair -> pair[1])); | ||
config = | ||
config.resolveWith( | ||
ConfigFactory.parseMap(map), | ||
ConfigResolveOptions.defaults().setAllowUnresolved(true)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem like this part show twice in this file. Could you refactor it with new method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
String configFile = getTestConfigFile(configurePath); | ||
SparkCommandArgs sparkCommandArgs = new SparkCommandArgs(); | ||
sparkCommandArgs.setConfigFile(configFile); | ||
sparkCommandArgs.setCheckConfig(false); | ||
sparkCommandArgs.setVariables(null); | ||
sparkCommandArgs.setVariables(Collections.singletonList("intVal=1")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted
@@ -17,16 +17,36 @@ | |||
|
|||
package org.apache.seatunnel.example.spark.v2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not touch example module.
@@ -0,0 +1,99 @@ | |||
# |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
d999cac
to
c964f1f
Compare
89f00f6
to
facd28f
Compare
...nnector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/UserVariableIT.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/org/apache/seatunnel/core/starter/flink/command/FlinkTaskExecuteCommand.java
Show resolved
Hide resolved
ff8bed4
to
aa00bfd
Compare
@Hisoka-X PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...nel-flink-13-starter/src/main/java/org/apache/seatunnel/core/starter/flink/FlinkStarter.java
Show resolved
Hide resolved
...flink-starter-common/src/main/java/org/apache/seatunnel/core/starter/flink/FlinkStarter.java
Show resolved
Hide resolved
How about add some intro in https://github.com/apache/seatunnel/blob/e5df7f00f8e21edcc5168c4f3dedfc7f85a4a150/docs/en/concept/config.md? Then user can easiler to found this feature. |
Sure, will do it. |
How about this one? |
a266f91
to
25da29d
Compare
25da29d
to
9d50885
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this ut, because we has e2e test
And in this ut, it's call clientCommandArgs.buildCommand()
in this method, it will set the variables to system properties. then the config parse read from system properties.
as we unified the process, we won't set the variables to system properties, then this test will be fail.
Done, PTAL |
docs/en/concept/config.md
Outdated
} | ||
``` | ||
|
||
In the above config, i define some variables, like `${rowNum}`, `${resName}`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the above config, i define some variables, like `${rowNum}`, `${resName}`. | |
In the above config, we define some variables, like `${rowNum}`, `${resName}`. |
docs/en/concept/config.md
Outdated
./bin/seatunnel.sh -c <this_config_file> -i rowNum=10 -i resName=fake -i strTemplate=abc -i nameVal=abc | ||
``` | ||
|
||
Then the finial submitted config is: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the finial submitted config is: | |
Then the final submitted config is: |
int fakeParallelism = 16; | ||
String username = "seatunnel=2.3.1"; | ||
String password = "dsjr42=4wfskahdsd=w1chh"; | ||
String fakeSourceTable = "fake"; | ||
String fakeSinkTable = "sink"; | ||
String list = "[par1=20230829,par2=20230829]"; | ||
String blankSpace = "2023-12-26 11:30:00"; | ||
String[] args = { | ||
"-c", | ||
"/args/user_defined_params.conf", | ||
"-e", | ||
"local", | ||
"-i", | ||
"fake_source_table=" + fakeSourceTable, | ||
"-i", | ||
"fake_parallelism=" + fakeParallelism, | ||
"-i", | ||
"fake_sink_table=" + fakeSinkTable, | ||
"-i", | ||
"password=" + password, | ||
"-i", | ||
"username=" + username, | ||
"-i", | ||
"blankSpace=" + blankSpace, | ||
"-i", | ||
"list=" + list, | ||
"-i", | ||
"sql=" + "\"select a , b from fake_source_table\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need add test case like this:
String username = "seatunnel=2.3.1";
String password = "dsjr42=4wfskahdsd=w1chh";
String list = "[par1=20230829,par2=20230829]";
String blankSpace = "2023-12-26 11:30:00";
String sql = "\"select a , b from fake_source_table\""
It contains =
,
, \"
so on
e2a6f12
to
645b1d4
Compare
.collect(Collectors.toMap(pair -> pair[0], pair -> pair[1])); | ||
config = | ||
config.resolveWith( | ||
ConfigFactory.parseMap(map), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use parameter map as arg in here but https://github.com/apache/seatunnel/pull/6387/files#diff-f4fa1a9b065718cc135d232712063b7b3a9135933396dd2674253da754d95c86R122 use system properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, i need change all of them to system properties.
when i test the array type variabel replacement, i find it only can be replace when use system properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please retrigger failed CI.
Thanks @liunaijie for updated. But I think we should find the reason instead of disable it. |
+1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh almost forgot this one. LGTM. Thanks @liunaijie
Purpose of this pull request
close #6376
Does this PR introduce any user-facing change?
No
How was this patch tested?
add example to test.
Check list
New License Guide
release-note
.