|
| 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 | +# A pipeline that reads from iceberg table and writes to AlloyDB. |
| 19 | + |
| 20 | +pipeline: |
| 21 | + type: chain |
| 22 | + transforms: |
| 23 | + # Step 1: Reading data from Iceberg |
| 24 | + - type: ReadFromIceberg |
| 25 | + name: ReadFromIcebergTable |
| 26 | + config: |
| 27 | + table: "db.users.NY" |
| 28 | + catalog_name: "hadoop_catalog" |
| 29 | + catalog_properties: |
| 30 | + type: "hadoop" |
| 31 | + warehouse: "gs://MY-WAREHOUSE" |
| 32 | + # Hadoop catalog config required to run pipeline locally |
| 33 | + # Omit if running on Dataflow |
| 34 | + config_properties: |
| 35 | + "fs.gs.auth.type": "SERVICE_ACCOUNT_JSON_KEYFILE" |
| 36 | + "fs.gs.auth.service.account.json.keyfile": "/path/to/service/account/key.json" |
| 37 | + |
| 38 | + # Step 2: Write records out to AlloyDB |
| 39 | + # To run pipeline locally, Modify alloydbIpType to PUBLIC |
| 40 | + - type: WriteToJdbc |
| 41 | + name: WriteToAlloyDBTable |
| 42 | + config: |
| 43 | + location: "users" |
| 44 | + driver_class_name: "org.postgresql.Driver" |
| 45 | + jdbc_url: "jdbc:postgresql:///db?socketFactory=com.google.cloud.alloydb.SocketFactory&alloydbInstanceName=projects/<PROJECT>/locations/<REGION>/clusters/<CLUSTER>/instances/<INSTANCE>&alloydbIpType=PRIVATE" |
| 46 | + username: "<YOUR_USERNAME>" |
| 47 | + password: "<YOUR_PASSWORD>" |
| 48 | + |
| 49 | +# Expected: |
| 50 | +# Row(id=3, name='Smith', email='smith@example.com', zip='NY') |
| 51 | +# Row(id=4, name='Beamberg', email='beamberg@example.com', zip='NY') |
0 commit comments