Skip to content

Commit c367bd3

Browse files
authored
Add Iceberg to AlloyDB Blueprint (#36036)
* Add Iceberg to AlloyDB Blueprint * use WriteToJdbc * Fix Formatting * Fix description * Add place holders for creds
1 parent 32d53ab commit c367bd3

2 files changed

Lines changed: 55 additions & 2 deletions

File tree

sdks/python/apache_beam/yaml/examples/testing/examples_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,8 @@ def _kafka_test_preprocessor(
678678
'test_ml_preprocessing_yaml',
679679
'test_anomaly_scoring_yaml',
680680
'test_wordCountInclude_yaml',
681-
'test_wordCountImport_yaml'
681+
'test_wordCountImport_yaml',
682+
'test_iceberg_to_alloydb_yaml'
682683
])
683684
def _io_write_test_preprocessor(
684685
test_spec: dict, expected: List[str], env: TestEnvironment):
@@ -749,7 +750,8 @@ def _file_io_read_test_preprocessor(
749750
return test_spec
750751

751752

752-
@YamlExamplesTestSuite.register_test_preprocessor(['test_iceberg_read_yaml'])
753+
@YamlExamplesTestSuite.register_test_preprocessor(
754+
['test_iceberg_read_yaml', 'test_iceberg_to_alloydb_yaml'])
753755
def _iceberg_io_read_test_preprocessor(
754756
test_spec: dict, expected: List[str], env: TestEnvironment):
755757
"""
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)