|
| 1 | +# coding=utf-8 |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed with |
| 5 | +# this work for additional information regarding copyright ownership. |
| 6 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | +# (the "License"); you may not use this file except in compliance with |
| 8 | +# the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +# |
| 18 | + |
| 19 | +pipeline: |
| 20 | + type: chain |
| 21 | + transforms: |
| 22 | + - type: Create |
| 23 | + config: |
| 24 | + elements: |
| 25 | + - {sdk: MapReduce, year: 2004} |
| 26 | + - {sdk: MillWheel, year: 2008} |
| 27 | + - {sdk: Flume, year: 2010} |
| 28 | + - {sdk: Dataflow, year: 2014} |
| 29 | + - {sdk: Apache Beam, year: 2016} |
| 30 | + - type: MapToFields |
| 31 | + name: ToRoman |
| 32 | + config: |
| 33 | + language: java |
| 34 | + fields: |
| 35 | + tool_name: sdk |
| 36 | + year: |
| 37 | + callable: | |
| 38 | + import org.apache.beam.sdk.values.Row; |
| 39 | + import java.util.function.Function; |
| 40 | + import com.github.chaosfirebolt.converter.RomanInteger; |
| 41 | +
|
| 42 | + public class MyFunction implements Function<Row, String> { |
| 43 | + public String apply(Row row) { |
| 44 | + return RomanInteger.parse( |
| 45 | + String.valueOf(row.getInt64("year"))).toString(); |
| 46 | + } |
| 47 | + } |
| 48 | + dependencies: |
| 49 | + - 'com.github.chaosfirebolt.converter:roman-numeral-converter:2.1.0' |
| 50 | + - type: LogForTesting |
| 51 | + |
| 52 | +# Expected: |
| 53 | +# Row(tool_name='MapReduce', year='MMIV') |
| 54 | +# Row(tool_name='MillWheel', year='MMVIII') |
| 55 | +# Row(tool_name='Flume', year='MMX') |
| 56 | +# Row(tool_name='Dataflow', year='MMXIV') |
| 57 | +# Row(tool_name='Apache Beam', year='MMXVI') |
0 commit comments