Мне нужно получить год из метки времени при преобразовании моих необработанных данных в клей AWS. Ниже я пытаюсь, но не работаю.
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
from pyspark.sql.functions import *
## @params: [JOB_NAME]
args = getResolvedOptions(sys.argv, ['JOB_NAME'])
sc = SparkContext()
glueContext = GlueContext(sc)
spark = glueContext.spark_session
job = Job(glueContext)
job.init(args['JOB_NAME'], args)
datasource0 = glueContext.create_dynamic_frame.from_catalog(database = "default", table_name = "xxx", transformation_ctx = "datasource0")
def AddDateYearForPartition(rec):
rec["year"] = year(rec.date_entered);
return rec
mapped_dyF = Map.apply(frame = datasource0, f = AddDateYearForPartition)