|
10 | 10 | from ydb.tests.tools.datastreams_helpers.test_yds_base import TestYdsBase
|
11 | 11 | from ydb.tests.fq.generic.utils.settings import Settings
|
12 | 12 |
|
| 13 | +DEBUG = 0 |
13 | 14 | TESTCASES = [
|
14 | 15 | # 0
|
15 | 16 | (
|
|
187 | 188 | $enriched = select e.id as id,
|
188 | 189 | $formatTime(DateTime::ParseIso8601(e.ts)) as ts,
|
189 | 190 | e.user as user_id,
|
| 191 | + u.id as uid, |
190 | 192 | u.name as name,
|
191 | 193 | u.age as age
|
192 | 194 | from
|
|
201 | 203 | [
|
202 | 204 | (
|
203 | 205 | '{"id":1,"ts":"20240701T113344","ev_type":"foo1","user":2}',
|
204 |
| - '{"id":1,"ts":"11:33:44","user_id":2,"name":"Petr","age":25}', |
| 206 | + '{"id":1,"ts":"11:33:44","uid":2,"user_id":2,"name":"Petr","age":25}', |
205 | 207 | ),
|
206 | 208 | (
|
207 | 209 | '{"id":2,"ts":"20240701T112233","ev_type":"foo2","user":1}',
|
208 |
| - '{"id":2,"ts":"11:22:33","user_id":1,"name":"Anya","age":15}', |
| 210 | + '{"id":2,"ts":"11:22:33","uid":1,"user_id":1,"name":"Anya","age":15}', |
209 | 211 | ),
|
210 | 212 | (
|
211 | 213 | '{"id":3,"ts":"20240701T113355","ev_type":"foo3","user":100}',
|
212 |
| - '{"id":3,"ts":"11:33:55","user_id":100,"name":null,"age":null}', |
| 214 | + '{"id":3,"ts":"11:33:55","uid":null,"user_id":100,"name":null,"age":null}', |
213 | 215 | ),
|
214 | 216 | (
|
215 | 217 | '{"id":4,"ts":"20240701T113356","ev_type":"foo4","user":3}',
|
216 |
| - '{"id":4,"ts":"11:33:56","user_id":3,"name":"Masha","age":17}', |
| 218 | + '{"id":4,"ts":"11:33:56","uid":3,"user_id":3,"name":"Masha","age":17}', |
217 | 219 | ),
|
218 | 220 | (
|
219 | 221 | '{"id":5,"ts":"20240701T113357","ev_type":"foo5","user":3}',
|
220 |
| - '{"id":5,"ts":"11:33:57","user_id":3,"name":"Masha","age":17}', |
| 222 | + '{"id":5,"ts":"11:33:57","uid":3,"user_id":3,"name":"Masha","age":17}', |
221 | 223 | ),
|
222 | 224 | (
|
223 | 225 | '{"id":6,"ts":"20240701T112238","ev_type":"foo6","user":1}',
|
224 |
| - '{"id":6,"ts":"11:22:38","user_id":1,"name":"Anya","age":15}', |
| 226 | + '{"id":6,"ts":"11:22:38","uid":1,"user_id":1,"name":"Anya","age":15}', |
225 | 227 | ),
|
226 | 228 | (
|
227 | 229 | '{"id":7,"ts":"20240701T113349","ev_type":"foo7","user":2}',
|
228 |
| - '{"id":7,"ts":"11:33:49","user_id":2,"name":"Petr","age":25}', |
| 230 | + '{"id":7,"ts":"11:33:49","uid":2,"user_id":2,"name":"Petr","age":25}', |
229 | 231 | ),
|
230 | 232 | ]
|
231 | 233 | * 1000,
|
232 | 234 | ),
|
| 235 | + # 5 |
| 236 | + ( |
| 237 | + R''' |
| 238 | + $input = SELECT * FROM myyds.`{input_topic}` |
| 239 | + WITH ( |
| 240 | + FORMAT=json_each_row, |
| 241 | + SCHEMA ( |
| 242 | + id Int32, |
| 243 | + ts String, |
| 244 | + ev_type String, |
| 245 | + user Int32, |
| 246 | + ) |
| 247 | + ) ; |
| 248 | +
|
| 249 | + $enriched = select e.id as id, |
| 250 | + e.user as user_id, |
| 251 | + u.id as uid |
| 252 | + from |
| 253 | + $input as e |
| 254 | + left join {streamlookup} ydb_conn_{table_name}.`users` as u |
| 255 | + on(e.user = u.id) |
| 256 | + ; |
| 257 | +
|
| 258 | + insert into myyds.`{output_topic}` |
| 259 | + select Unwrap(Yson::SerializeJson(Yson::From(TableRow()))) from $enriched; |
| 260 | + ''', |
| 261 | + [ |
| 262 | + ( |
| 263 | + '{"id":1,"ts":"20240701T113344","ev_type":"foo1","user":2}', |
| 264 | + '{"id":1,"uid":2,"user_id":2}', |
| 265 | + ), |
| 266 | + ( |
| 267 | + '{"id":2,"ts":"20240701T112233","ev_type":"foo2","user":1}', |
| 268 | + '{"id":2,"uid":1,"user_id":1}', |
| 269 | + ), |
| 270 | + ( |
| 271 | + '{"id":3,"ts":"20240701T113355","ev_type":"foo3","user":100}', |
| 272 | + '{"id":3,"uid":null,"user_id":100}', |
| 273 | + ), |
| 274 | + ( |
| 275 | + '{"id":4,"ts":"20240701T113356","ev_type":"foo4","user":3}', |
| 276 | + '{"id":4,"uid":3,"user_id":3}', |
| 277 | + ), |
| 278 | + ], |
| 279 | + ), |
233 | 280 | ]
|
234 | 281 |
|
235 | 282 |
|
@@ -324,9 +371,10 @@ def test_streamlookup(
|
324 | 371 | offset += 500
|
325 | 372 |
|
326 | 373 | read_data = self.read_stream(len(messages))
|
327 |
| - print(streamlookup, testcase, file=sys.stderr) |
328 |
| - print(sql, file=sys.stderr) |
329 |
| - print(*zip(messages, read_data), file=sys.stderr, sep="\n") |
| 374 | + if DEBUG: |
| 375 | + print(streamlookup, testcase, file=sys.stderr) |
| 376 | + print(sql, file=sys.stderr) |
| 377 | + print(*zip(messages, read_data), file=sys.stderr, sep="\n") |
330 | 378 | for r, exp in zip(read_data, messages):
|
331 | 379 | r = json.loads(r)
|
332 | 380 | exp = json.loads(exp[1])
|
|
0 commit comments