기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
FlatMap 수업
컬렉션의 각DynamicFrame
항목에 변환을 적용합니다. 결과는 하나로DynamicFrame
병합되지 않고 컬렉션으로 보존됩니다.
다음 예시 FlatMap
다음 예제 스니펫은 동적 프레임 컬렉션에서ResolveChoice
변환을 에 적용할 때 이를 사용하는 방법을 보여줍니다FlatMap
. 입력에 사용되는 데이터는 플레이스홀더 Amazon S3 주소에 있는 JSON에s3://bucket/path-for-data/sample.json
있으며 다음 데이터를 포함합니다.
[{ "firstname": "Arnav", "lastname": "Desai", "address": { "street": "6 Anyroad Avenue", "city": "London", "state": "England", "country": "UK" }, "phone": 17235550101, "affiliations": [ "General Anonymous Example Products", "Example Independent Research", "Government Department of Examples" ] }, { "firstname": "Mary", "lastname": "Major", "address": { "street": "7821 Spot Place", "city": "Centerville", "state": "OK", "country": "US" }, "phone": 19185550023, "affiliations": [ "Example Dot Com", "Example Independent Research", "Example.io" ] }, { "firstname": "Paulo", "lastname": "Santos", "address": { "street": "123 Maple Street", "city": "London", "state": "Ontario", "country": "CA" }, "phone": 12175550181, "affiliations": [ "General Anonymous Example Products", "Example Dot Com" ] }]
예 ResolveChoice a에 DynamicFrameCollection 적용하고 출력을 표시합니다.
#Read DynamicFrame datasource = glueContext.create_dynamic_frame_from_options("s3", connection_options = {"paths":["s3://bucket/path/to/file/mysamplejson.json"]}, format="json") datasource.printSchema() datasource.show() ## Split to create a DynamicFrameCollection split_frame=datasource.split_fields(["firstname","lastname","address"],"personal_info","business_info") split_frame.keys() print("---") ## Use FlatMap to run ResolveChoice kwargs = {"choice": "cast:string"} flat = FlatMap.apply(split_frame, ResolveChoice, frame_name="frame", transformation_ctx='tcx', **kwargs) flat.keys() ##Select one of the DynamicFrames personal_info = flat.select("personal_info") personal_info.printSchema() personal_info.show() print("---") business_info = flat.select("business_info") business_info.printSchema() business_info.show()
중요
호출FlatMap.apply
시frame_name
파라미터는 이어야 합니다"frame"
. 현재 다른 값은 허용되지 않습니다.
root |-- firstname: string |-- lastname: string |-- address: struct | |-- street: string | |-- city: string | |-- state: string | |-- country: string |-- phone: long |-- affiliations: array | |-- element: string --- { "firstname": "Mary", "lastname": "Major", "address": { "street": "7821 Spot Place", "city": "Centerville", "state": "OK", "country": "US" }, "phone": 19185550023, "affiliations": [ "Example Dot Com", "Example Independent Research", "Example.io" ] } { "firstname": "Paulo", "lastname": "Santos", "address": { "street": "123 Maple Street", "city": "London", "state": "Ontario", "country": "CA" }, "phone": 12175550181, "affiliations": [ "General Anonymous Example Products", "Example Dot Com" ] } --- root |-- firstname: string |-- lastname: string |-- address: struct | |-- street: string | |-- city: string | |-- state: string | |-- country: string { "firstname": "Mary", "lastname": "Major", "address": { "street": "7821 Spot Place", "city": "Centerville", "state": "OK", "country": "US" } } { "firstname": "Paulo", "lastname": "Santos", "address": { "street": "123 Maple Street", "city": "London", "state": "Ontario", "country": "CA" } } --- root |-- phone: long |-- affiliations: array | |-- element: string { "phone": 19185550023, "affiliations": [ "Example Dot Com", "Example Independent Research", "Example.io" ] } { "phone": 12175550181, "affiliations": [ "General Anonymous Example Products", "Example Dot Com" ] }
메서드
__call__ (dfc BaseTransform, frame, frame, transformation_ctx = “”, **base_kwargs)
컬렉션의 각 DynamicFrame
에 변환을 적용하고 결과를 플랫합니다.
dfc
– 플랫맵할DynamicFrameCollection
입니다(필수).BaseTransform
–GlueTransform
로부터 얻어진 변환을 사용하여 컬렉션의 각 멤버에게 적용합니다(필수).frame_name
- 컬렉션의 요소를 전달하기 위한 인수 이름입니다(필수).transformation_ctx
- 고유 문자열을 통해 상태 정보를 확인합니다(선택 사항).base_kwargs
- 기본 변환으로 전달을 위한 인수입니다(필수).
DynamicFrameCollection
원본의 변환을 각 DynamicFrame
에 적용하여 생성한 새로운 DynamicFrameCollection
을 반환합니다.
apply(cls, *args, **kwargs)
GlueTransform
apply에서 상속됩니다.
name(cls)
GlueTransform
name에서 상속됩니다.
describeArgs(cls)
GlueTransform
describeArgs에서 상속됩니다.
describeReturn(cls)
GlueTransform
describeReturn에서 상속됩니다.
describeTransform(cls)
GlueTransform
describeTransform에서 상속됩니다.
describeErrors(cls)
GlueTransform
describeErrors에서 상속됩니다.
describe(cls)
GlueTransform
describe에서 상속됩니다.