forked from apache/seatunnel
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature][starter] support user define parameter on spark/flink engine
- Loading branch information
Showing
8 changed files
with
282 additions
and
13 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
52 changes: 52 additions & 0 deletions
52
...e/src/main/java/org/apache/seatunnel/example/flink/v2/SeaTunnelFlinkVariablesExample.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,52 @@ | ||
/* | ||
* 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.apache.seatunnel.example.flink.v2; | ||
|
||
import org.apache.seatunnel.core.starter.SeaTunnel; | ||
import org.apache.seatunnel.core.starter.exception.CommandException; | ||
import org.apache.seatunnel.core.starter.flink.args.FlinkCommandArgs; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.net.URISyntaxException; | ||
import java.net.URL; | ||
import java.nio.file.Paths; | ||
import java.util.Collections; | ||
|
||
public class SeaTunnelFlinkVariablesExample { | ||
|
||
public static void main(String[] args) | ||
throws FileNotFoundException, URISyntaxException, CommandException { | ||
String configurePath = | ||
args.length > 0 ? args[0] : "/examples/fake_to_console.variables.conf"; | ||
String configFile = getTestConfigFile(configurePath); | ||
FlinkCommandArgs flinkCommandArgs = new FlinkCommandArgs(); | ||
flinkCommandArgs.setConfigFile(configFile); | ||
flinkCommandArgs.setCheckConfig(false); | ||
flinkCommandArgs.setVariables(Collections.singletonList("nameVal=abc")); | ||
SeaTunnel.run(flinkCommandArgs.buildCommand()); | ||
} | ||
|
||
public static String getTestConfigFile(String configFile) | ||
throws FileNotFoundException, URISyntaxException { | ||
URL resource = SeaTunnelApiExample.class.getResource(configFile); | ||
if (resource == null) { | ||
throw new FileNotFoundException("Can't find config file: " + configFile); | ||
} | ||
return Paths.get(resource.toURI()).toString(); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...nel-flink-connector-v2-example/src/main/resources/examples/fake_to_console.variables.conf
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,61 @@ | ||
# | ||
# 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. | ||
# | ||
###### | ||
###### This config file is a demonstration of streaming processing in seatunnel config | ||
###### | ||
|
||
env { | ||
job.mode = "BATCH" | ||
parallelism = 2 | ||
} | ||
|
||
source { | ||
# This is a example source plugin **only for test and demonstrate the feature source plugin** | ||
FakeSource { | ||
result_table_name = "fake" | ||
row.num = 16 | ||
string.template = ["abc", "def"] | ||
schema = { | ||
fields { | ||
name = "string" | ||
age = "int" | ||
} | ||
} | ||
} | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of source plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/source-v2 | ||
} | ||
|
||
transform { | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of transform plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/transform-v2 | ||
sql { | ||
source_table_name = "fake" | ||
query = "select * from fake where name = '"${nameVal}"' " | ||
result_table_name = "sql" | ||
} | ||
} | ||
|
||
sink { | ||
Console { | ||
} | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of sink plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/sink-v2 | ||
} |
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
99 changes: 99 additions & 0 deletions
99
...atunnel-spark-connector-v2-example/src/main/resources/examples/spark.batch.variables.conf
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,99 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
###### | ||
###### This config file is a demonstration of batch processing in SeaTunnel config | ||
###### | ||
|
||
env { | ||
# You can set spark configuration here | ||
# see available properties defined by spark: https://spark.apache.org/docs/latest/configuration.html#available-properties | ||
#job.mode = BATCH | ||
job.name = "SeaTunnel" | ||
spark.executor.instances = 1 | ||
spark.executor.cores = 1 | ||
spark.executor.memory = "1g" | ||
spark.master = local | ||
} | ||
|
||
source { | ||
# This is a example input plugin **only for test and demonstrate the feature input plugin** | ||
FakeSource { | ||
row.num = 16 | ||
parallelism = 2 | ||
schema = { | ||
fields { | ||
c_map = "map<string, string>" | ||
c_array = "array<int>" | ||
c_string = string | ||
c_boolean = boolean | ||
c_tinyint = tinyint | ||
c_smallint = smallint | ||
c_int = int | ||
c_bigint = bigint | ||
c_float = float | ||
c_double = double | ||
c_decimal = "decimal(30, 8)" | ||
c_null = "null" | ||
c_bytes = bytes | ||
c_date = date | ||
c_timestamp = timestamp | ||
} | ||
} | ||
result_table_name = "fake" | ||
} | ||
|
||
# You can also use other input plugins, such as hdfs | ||
# hdfs { | ||
# result_table_name = "accesslog" | ||
# path = "hdfs://hadoop-cluster-01/nginx/accesslog" | ||
# format = "json" | ||
# } | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of input plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/source-v2 | ||
} | ||
|
||
transform { | ||
# split data by specific delimiter | ||
|
||
# you can also use other transform plugins, such as sql | ||
sql { | ||
source_table_name = "fake" | ||
query = "select c_map,c_array,c_string,c_boolean,c_tinyint,c_smallint,c_int,c_bigint,c_float,c_double,c_null,c_bytes,c_date,c_timestamp from fake where c_int = "${intVal}" " | ||
result_table_name = "sql" | ||
} | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of transform plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/transform-v2 | ||
} | ||
|
||
sink { | ||
# choose stdout output plugin to output data to console | ||
Console { | ||
parallelism = 2 | ||
} | ||
|
||
# you can also you other output plugins, such as sql | ||
# hdfs { | ||
# path = "hdfs://hadoop-cluster-01/nginx/accesslog_processed" | ||
# save_mode = "append" | ||
# } | ||
|
||
# If you would like to get more information about how to configure seatunnel and see full list of output plugins, | ||
# please go to https://seatunnel.apache.org/docs/category/sink-v2 | ||
} |