-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexampleScript.py
49 lines (44 loc) · 1.5 KB
/
exampleScript.py
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
#
# This is an example of a script for the ETL job, this one is generated in AWS console
# The one we'll generate using the createScript API is a bit different, as it's missing the ApplyMapping phase
#
import sys
from awsglue.transforms import *
from awsglue.utils import getResolvedOptions
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.job import Job
args = getResolvedOptions(sys.argv, ["JOB_NAME"])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args["JOB_NAME"], args)
# Script generated for node S3 bucket
S3bucket_node1 = glueContext.create_dynamic_frame.from_catalog(
database="dynamoathenadb",
table_name="dynamoathenastack_dynamoathenatable55d76dac_1byymlxk3b3of",
transformation_ctx="S3bucket_node1",
)
# Script generated for node ApplyMapping
ApplyMapping_node2 = ApplyMapping.apply(
frame=S3bucket_node1,
mappings=[
("newvalue1", "long", "newvalue1", "long"),
("newvalue", "string", "newvalue", "string"),
("pk", "string", "pk", "string"),
],
transformation_ctx="ApplyMapping_node2",
)
# Script generated for node S3 bucket
S3bucket_node3 = glueContext.write_dynamic_frame.from_options(
frame=ApplyMapping_node2,
connection_type="s3",
format="glueparquet",
connection_options={
"path": "s3://aws-glue-cirit-dynamo-athena-test/",
"partitionKeys": [],
},
transformation_ctx="S3bucket_node3",
)
job.commit()