forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_data.py
More file actions
188 lines (168 loc) · 5.56 KB
/
input_data.py
File metadata and controls
188 lines (168 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# coding=utf-8
#
# 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.
#
from apache_beam.io.gcp.pubsub import PubsubMessage
# This file contains the input data to be requested by the example tests, if
# needed.
def text_data():
return '\n'.join([
"Fool\tThou shouldst not have been old till thou hadst",
"\tbeen wise.",
"KING LEAR\tNothing will come of nothing: speak again.",
"\tNever, never, never, never, never!"
])
def iceberg_dynamic_destinations_users_data():
return [{
'id': 3, 'name': 'Smith', 'email': 'smith@example.com', 'zip': 'NY'
},
{
'id': 4,
'name': 'Beamberg',
'email': 'beamberg@example.com',
'zip': 'NY'
}]
def products_csv():
return '\n'.join([
'transaction_id,product_name,category,price',
'T0012,Headphones,Electronics,59.99',
'T5034,Leather Jacket,Apparel,109.99',
'T0024,Aluminum Mug,Kitchen,29.99',
'T0104,Headphones,Electronics,59.99',
'T0302,Monitor,Electronics,249.99'
])
def youtube_comments_csv():
return '\n'.join([
'video_id,comment_text,likes,replies',
'XpVt6Z1Gjjo,I AM HAPPY,1,1',
'XpVt6Z1Gjjo,I AM SAD,1,1',
'XpVt6Z1Gjjo,§ÁĐ,1,1'
])
def spanner_orders_data():
return [{
'order_id': 1,
'customer_id': 1001,
'product_id': 2001,
'order_date': '24-03-24',
'order_amount': 150,
},
{
'order_id': 2,
'customer_id': 1002,
'product_id': 2002,
'order_date': '19-04-24',
'order_amount': 90,
},
{
'order_id': 3,
'customer_id': 1003,
'product_id': 2003,
'order_date': '7-05-24',
'order_amount': 110,
}]
def shipments_data():
return [{
'shipment_id': 'S1',
'customer_id': 'C1',
'shipment_date': '2023-05-01',
'shipment_cost': 150.0,
'customer_name': 'Alice',
'customer_email': 'alice@example.com'
},
{
'shipment_id': 'S2',
'customer_id': 'C2',
'shipment_date': '2023-06-12',
'shipment_cost': 300.0,
'customer_name': 'Bob',
'customer_email': 'bob@example.com'
},
{
'shipment_id': 'S3',
'customer_id': 'C1',
'shipment_date': '2023-05-10',
'shipment_cost': 20.0,
'customer_name': 'Alice',
'customer_email': 'alice@example.com'
},
{
'shipment_id': 'S4',
'customer_id': 'C4',
'shipment_date': '2024-07-01',
'shipment_cost': 150.0,
'customer_name': 'Derek',
'customer_email': 'derek@example.com'
},
{
'shipment_id': 'S5',
'customer_id': 'C5',
'shipment_date': '2023-05-09',
'shipment_cost': 300.0,
'customer_name': 'Erin',
'customer_email': 'erin@example.com'
},
{
'shipment_id': 'S6',
'customer_id': 'C4',
'shipment_date': '2024-07-02',
'shipment_cost': 150.0,
'customer_name': 'Derek',
'customer_email': 'derek@example.com'
}]
def bigtable_data():
return [{
'product_id': '1', 'product_name': 'pixel 5', 'product_stock': '2'
}, {
'product_id': '2', 'product_name': 'pixel 6', 'product_stock': '4'
}, {
'product_id': '3', 'product_name': 'pixel 7', 'product_stock': '20'
}, {
'product_id': '4', 'product_name': 'pixel 8', 'product_stock': '10'
}, {
'product_id': '5', 'product_name': 'pixel 11', 'product_stock': '3'
}, {
'product_id': '6', 'product_name': 'pixel 12', 'product_stock': '7'
}, {
'product_id': '7', 'product_name': 'pixel 13', 'product_stock': '8'
}, {
'product_id': '8', 'product_name': 'pixel 14', 'product_stock': '3'
}]
def bigquery_data():
return [{
'customer_id': 1001,
'customer_name': 'Alice',
'customer_email': 'alice@gmail.com'
},
{
'customer_id': 1002,
'customer_name': 'Bob',
'customer_email': 'bob@gmail.com'
},
{
'customer_id': 1003,
'customer_name': 'Claire',
'customer_email': 'claire@gmail.com'
}]
def pubsub_messages_data():
"""
Provides a list of PubsubMessage objects for testing.
"""
return [
PubsubMessage(data=b"{\"label\": \"37a\", \"rank\": 1}", attributes={}),
PubsubMessage(data=b"{\"label\": \"37b\", \"rank\": 4}", attributes={}),
PubsubMessage(data=b"{\"label\": \"37c\", \"rank\": 3}", attributes={}),
PubsubMessage(data=b"{\"label\": \"37d\", \"rank\": 2}", attributes={}),
]