-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOracle To S3 Lakehouse.zpln
538 lines (538 loc) · 18.4 KB
/
Oracle To S3 Lakehouse.zpln
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
{
"paragraphs": [
{
"title": "Spark Configuration ",
"text": "%spark.conf\nspark.jars.packages io.delta:delta-core_2.11:0.6.0,com.amazonaws:aws-java-sdk:1.7.4.2,org.apache.hadoop:hadoop-aws:2.7.4,org.apache.iceberg:iceberg-spark3-runtime:0.11.0,software.amazon.awssdk:bundle:2.15.40,software.amazon.awssdk:url-connection-client:2.15.40,net.java.dev.jets3t:jets3t:0.9.4\nspark.hadoop.fs.s3a.access.key=z.get(\"S3 Access Key\")\nspark.hadoop.fs.s3a.secret.key=z.get(\"S3 Secret Key\")\nspark.executor.extraJavaOptions=-Dcom.amazonaws.services.s3.enableV4=true\nspark.driver.extraJavaOptions=-Dcom.amazonaws.services.s3.enableV4=true\nspark.sql.extensions=org.apache.iceberg.spark.extensions.IcebergSparkSessionExtensions\nspark.sql.catalog.lakehouse=org.apache.iceberg.spark.SparkCatalog\nspark.sql.catalog.lakehouse.warehouse=z.get(\"S3 Warehouse Location\")\nspark.sql.catalog.lakehouse.catalog-impl=org.apache.iceberg.aws.glue.GlueCatalog",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:20:58+0000",
"progress": 0,
"config": {
"editorSetting": {
"language": "text",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/text",
"fontSize": 9,
"editorHide": true,
"title": true,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_204131832",
"id": "paragraph_1615528250801_1067881259",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:07+0000",
"dateFinished": "2021-03-18T07:17:07+0000",
"status": "FINISHED",
"focus": true,
"$$hashKey": "object:189"
},
{
"title": "Oracle Credentials",
"text": "%spark\nz.put(\"Oracle DB Host\", z.textbox(\"Oracle DB Host\", \"\"))\nz.put(\"Oracle DB Port\", z.textbox(\"Oracle DB Port\", \"\"))\nz.put(\"Oracle DB SID\", z.textbox(\"Oracle DB SID\", \"\"))\nz.put(\"Oracle DB Username\", z.textbox(\"Oracle DB Username\", \"\"))\nz.put(\"Oracle DB Password\", z.textbox(\"Oracle DB Password\", \"\"))\nz.put(\"Oracle DB Table\", z.textbox(\"Oracle DB Table\", \"\"))\nz.put(\"Table Local Alias\", z.textbox(\"Table Local Alias\", \"\"))\nz.put(\"SQL\", z.textbox(\"SQL Query on Table Local Alias\", \"\"))\nz.put(\"Oracle DB Primary Column\", z.textbox(\"Oracle DB Primary Column\", \"\"))\nz.put(\"Oracle DB Increment Column\", z.textbox(\"Oracle DB Increment Column\", \"\"))\nprint(\"\")",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:20:58+0000",
"progress": 0,
"config": {
"tableHide": false,
"editorSetting": {
"language": "scala",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/scala",
"fontSize": 9,
"editorHide": true,
"title": true,
"results": {},
"enabled": true
},
"settings": {
"params": {
"S3 Access Key": "",
"S3 Secret Key": "",
"Oracle DB Host": "",
"Oracle DB Port": "",
"Oracle DB SID": "",
"Oracle DB Username": "",
"Oracle DB Password": "",
"Oracle DB Table": "",
"Oracle DB Query": "",
"Oracle DB Increment Column": "",
"Oracle DB Table Local Alias": "",
"Table Local Alias": "",
"SQL Query on Table Local Alias": "",
"Oracle DB Primary Column": "",
"S3 Output Table": ""
},
"forms": {
"Oracle DB Host": {
"type": "TextBox",
"name": "Oracle DB Host",
"displayName": "Oracle DB Host",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:359"
},
"Oracle DB Port": {
"type": "TextBox",
"name": "Oracle DB Port",
"displayName": "Oracle DB Port",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:360"
},
"Oracle DB SID": {
"type": "TextBox",
"name": "Oracle DB SID",
"displayName": "Oracle DB SID",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:361"
},
"Oracle DB Username": {
"type": "TextBox",
"name": "Oracle DB Username",
"displayName": "Oracle DB Username",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:362"
},
"Oracle DB Password": {
"type": "TextBox",
"name": "Oracle DB Password",
"displayName": "Oracle DB Password",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:363"
},
"Oracle DB Table": {
"type": "TextBox",
"name": "Oracle DB Table",
"displayName": "Oracle DB Table",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:364"
},
"Table Local Alias": {
"type": "TextBox",
"name": "Table Local Alias",
"displayName": "Table Local Alias",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:365"
},
"SQL Query on Table Local Alias": {
"type": "TextBox",
"name": "SQL Query on Table Local Alias",
"displayName": "SQL Query on Table Local Alias",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:366"
},
"Oracle DB Primary Column": {
"type": "TextBox",
"name": "Oracle DB Primary Column",
"displayName": "Oracle DB Primary Column",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:367"
},
"Oracle DB Increment Column": {
"type": "TextBox",
"name": "Oracle DB Increment Column",
"displayName": "Oracle DB Increment Column",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:368"
}
}
},
"results": {},
"apps": [],
"runtimeInfos": {},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228980_881719495",
"id": "paragraph_1615788107314_2081252472",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:07+0000",
"dateFinished": "2021-03-18T07:17:08+0000",
"status": "FINISHED",
"$$hashKey": "object:190"
},
{
"text": "%spark\nz.put(\"S3 Access Key\", z.noteTextbox(\"S3 Access Key\", \"\"))\nz.put(\"S3 Secret Key\", z.noteTextbox(\"S3 Secret Key\", \"\"))\nz.put(\"S3 Warehouse Location\", z.noteTextbox(\"S3 Warehouse Location\", \"\"))\nz.put(\"S3 Output Table\", z.noteTextbox(\"S3 Output Table\", \"\"))",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:37:51+0000",
"progress": 0,
"config": {
"editorSetting": {
"language": "scala",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/scala",
"fontSize": 9,
"editorHide": false,
"results": {},
"enabled": true
},
"settings": {
"params": {
"S3 Access Key": "",
"S3 Secret Key": "",
"S3 Output Table": "",
"S3 Warehouse Location": ""
},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_1606497606",
"id": "paragraph_1615985219153_1827247078",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:08+0000",
"dateFinished": "2021-03-18T07:17:08+0000",
"status": "FINISHED",
"$$hashKey": "object:191"
},
{
"text": "%spark.pyspark\nprint(z.get('Oracle DB Table'))\n\ndf = spark.read \\\n .format(\"jdbc\") \\\n .option(\"url\", f\"jdbc:oracle:thin:@{z.get('Oracle DB Host')}:{z.get('Oracle DB Port')}/{z.get('Oracle DB SID')}\") \\\n .option(\"dbtable\", z.get('Oracle DB Table')) \\\n .option(\"user\", z.get('Oracle DB Username')) \\\n .option(\"password\", z.get('Oracle DB Password')) \\\n .option(\"driver\", \"oracle.jdbc.driver.OracleDriver\") \\\n .load()\n\ndf.createOrReplaceTempView(z.get('Table Local Alias'))\n",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:17:08+0000",
"progress": 0,
"config": {
"editorSetting": {
"language": "python",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/python",
"fontSize": 9,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_2102556262",
"id": "paragraph_1615893357128_1954123212",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:08+0000",
"dateFinished": "2021-03-18T07:17:11+0000",
"status": "FINISHED",
"$$hashKey": "object:192"
},
{
"title": "SQL Query on Table Local Alias",
"text": "%spark.sql\n\n{SQL} limit 3",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:17:11+0000",
"progress": 100,
"config": {
"editorSetting": {
"language": "sql",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/sql",
"fontSize": 9,
"title": true,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {
"jobUrl": {
"propertyName": "jobUrl",
"label": "SPARK JOB",
"tooltip": "View in Spark web UI",
"group": "spark",
"values": [
{
"jobUrl": "//4040-spark-zqchsm.local.zeppelin-project.org:8080/jobs/job?id=0",
"$$hashKey": "object:783"
}
],
"interpreterSettingId": "spark"
}
},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_287992730",
"id": "paragraph_1615882367095_1700520726",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:11+0000",
"dateFinished": "2021-03-18T07:17:18+0000",
"status": "FINISHED",
"$$hashKey": "object:193"
},
{
"text": "%spark.sql\nCREATE TABLE IF NOT EXISTS lakehouse.sampledb.{S3 Output Table} USING iceberg AS {SQL}",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:17:18+0000",
"progress": 0,
"config": {
"editorSetting": {
"language": "sql",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/sql",
"fontSize": 9,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_1152615493",
"id": "paragraph_1615528549981_865522288",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:18+0000",
"dateFinished": "2021-03-18T07:17:21+0000",
"status": "FINISHED",
"$$hashKey": "object:194"
},
{
"text": "%spark.pyspark\nmaxVal=spark.sql(f\"SELECT MAX({z.get('Oracle DB Increment Column')}) FROM lakehouse.sampledb.{z.get('S3 Output Table')}\").collect()[0][0]\nprint(maxVal)\n\nz.put(\"maxVal\", maxVal)",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:17:21+0000",
"progress": 100,
"config": {
"editorSetting": {
"language": "python",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/python",
"fontSize": 9,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {
"jobUrl": {
"propertyName": "jobUrl",
"label": "SPARK JOB",
"tooltip": "View in Spark web UI",
"group": "spark",
"values": [
{
"jobUrl": "//4040-spark-zqchsm.local.zeppelin-project.org:8080/jobs/job?id=1",
"$$hashKey": "object:869"
}
],
"interpreterSettingId": "spark"
}
},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_1367000948",
"id": "paragraph_1615885036622_2137552499",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:17:21+0000",
"dateFinished": "2021-03-18T07:18:06+0000",
"status": "FINISHED",
"$$hashKey": "object:195"
},
{
"text": "%spark.pyspark\nprint(f\"{z.get('SQL')} where {z.get('Oracle DB Increment Column')} > \\\"{z.get('maxVal')}\\\"\")\nspark.sql(f\"{z.get('SQL')} where {z.get('Oracle DB Increment Column')} > \\\"{z.get('maxVal')}\\\"\").count()",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:18:06+0000",
"progress": 0,
"config": {
"editorSetting": {
"language": "python",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/python",
"fontSize": 9,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {
"jobUrl": {
"propertyName": "jobUrl",
"label": "SPARK JOB",
"tooltip": "View in Spark web UI",
"group": "spark",
"values": [
{
"jobUrl": "//4040-spark-zqchsm.local.zeppelin-project.org:8080/jobs/job?id=2",
"$$hashKey": "object:915"
}
],
"interpreterSettingId": "spark"
}
},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_642894589",
"id": "paragraph_1615892727017_99879423",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:18:06+0000",
"dateFinished": "2021-03-18T07:18:09+0000",
"status": "FINISHED",
"$$hashKey": "object:196"
},
{
"text": "%spark.pyspark\n\npkCol = z.get(\"Oracle DB Primary Column\")\nmergeSql = f\"MERGE INTO lakehouse.sampledb.{z.get('S3 Output Table')} t USING ({z.get('SQL')} where {z.get('Oracle DB Increment Column')} > \\\"{z.get('maxVal')}\\\") u ON t.{pkCol} = u.{pkCol} WHEN MATCHED THEN UPDATE SET * WHEN NOT MATCHED THEN INSERT *\"\nprint(mergeSql)\nspark.sql(mergeSql)\n",
"user": "anonymous",
"dateUpdated": "2021-03-18T07:18:09+0000",
"progress": 100,
"config": {
"editorSetting": {
"language": "python",
"editOnDblClick": false,
"completionKey": "TAB",
"completionSupport": true
},
"colWidth": 12,
"editorMode": "ace/mode/python",
"fontSize": 9,
"results": {},
"enabled": true
},
"settings": {
"params": {},
"forms": {}
},
"results": {},
"apps": [],
"runtimeInfos": {
"jobUrl": {
"propertyName": "jobUrl",
"label": "SPARK JOB",
"tooltip": "View in Spark web UI",
"group": "spark",
"values": [
{
"jobUrl": "//4040-spark-zqchsm.local.zeppelin-project.org:8080/jobs/job?id=3",
"$$hashKey": "object:961"
},
{
"jobUrl": "//4040-spark-zqchsm.local.zeppelin-project.org:8080/jobs/job?id=4",
"$$hashKey": "object:962"
}
],
"interpreterSettingId": "spark"
}
},
"progressUpdateIntervalMs": 500,
"jobName": "paragraph_1616047228981_953674752",
"id": "paragraph_1615891142822_1411758685",
"dateCreated": "2021-03-18T06:00:28+0000",
"dateStarted": "2021-03-18T07:18:09+0000",
"dateFinished": "2021-03-18T07:20:58+0000",
"status": "FINISHED",
"$$hashKey": "object:197"
}
],
"name": "Oracle To S3 Lakehouse",
"id": "2G1N7JTYB",
"defaultInterpreterGroup": "spark",
"version": "0.9.0",
"noteParams": {
"S3 Access Key": "",
"S3 Secret Key": "",
"S3 Warehouse Location": "",
"S3 Output Table": ""
},
"noteForms": {
"S3 Access Key": {
"type": "TextBox",
"name": "S3 Access Key",
"displayName": "S3 Access Key",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:1787"
},
"S3 Secret Key": {
"type": "TextBox",
"name": "S3 Secret Key",
"displayName": "S3 Secret Key",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:1788"
},
"S3 Warehouse Location": {
"type": "TextBox",
"name": "S3 Warehouse Location",
"displayName": "S3 Warehouse Location",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:1789"
},
"S3 Output Table": {
"type": "TextBox",
"name": "S3 Output Table",
"displayName": "S3 Output Table",
"defaultValue": "",
"hidden": false,
"$$hashKey": "object:1790"
}
},
"angularObjects": {},
"config": {
"isZeppelinNotebookCronEnable": false,
"looknfeel": "default",
"personalizedMode": "false",
"noteFormTitle": " S3 Destination Credentials"
},
"info": {
"isRunning": false
},
"path": "/Oracle To S3 Lakehouse"
}