설명 실행 모드와 배포 모드를 혼동하기 쉽기 때문에 정답을 찾기 어려운 질문입니다. 심지어 문헌에서도 두 용어가 혼용되는 경우가 있습니다. Spark에는 클라이언트, 클러스터, 로컬 실행 모드의 세 가지 유효한 실행 모드만 있습니다. 실행 모드는 특정 프레임워크를 지칭하는 것이 아니라, 인프라가 서로 어떻게 위치하는지를 나타냅니다. 클라이언트 모드에서는 드라이버가 클러스터 외부 머신에 있습니다. 클러스터 모드에서는 드라이버가 클러스터 내부 머신에 있습니다. 마지막으로, 로컬 모드에서는 모든 Spark 인프라가 단일 컴퓨터의 단일 JVM(Java Virtual Machine)에서 시작되며, 이 컴퓨터에 드라이버도 포함됩니다. 배포 모드는 Spark를 클러스터 모드로 배포하는 방법과 Spark 외부의 특정 프레임워크를 사용하는 방법을 나타내는 경우가 많습니다. 사용 가능한 배포 모드는 독립형, Apache YARN, Apache Mesos, Kubernetes입니다. 클라이언트, 클러스터, 로컬 맞습니다. 이 모든 것이 Spark의 유효한 실행 모드입니다. 독립형, 클라이언트, 클러스터 아니요, 독립 실행형은 유효한 실행 모드가 아닙니다. 하지만 유효한 배포 모드입니다. 쿠버네티스, 로컬, 클라이언트 아니요, Kubernetes는 배포 모드이지만 실행 모드는 아닙니다. 클러스터, 서버, 로컬 아니요, 서버는 실행 모드가 아닙니다. 서버, 독립형, 클라이언트 아니요, 독립 실행형과 서버는 실행 모드가 아닙니다. 추가 정보: Apache Spark 내부 - 학습 저널
Associate-Developer-Apache-Spark 문제 63
다음 코드 블록 중 어느 것이 열 storeId가 문자열 유형으로 변환된 DataFrame transactionsDf의 복사본을 반환합니까?
정답: D
설명 이 질문은 캐스트 구문에 대한 지식을 묻습니다. 캐스트는 Column 클래스의 메서드입니다. 캐스트의 별칭인 Column.astype() 메서드를 사용하여 열 유형을 변환할 수도 있다는 점에 유의하세요. 자세한 내용은 아래 링크된 설명서에서 확인하세요. 자세한 정보: pyspark.sql.Column.cast - PySpark 3.1.2 문서 정적 노트북 | 동적 노트북: 테스트 2 참조
Associate-Developer-Apache-Spark 문제 64
아래 표시된 코드 블록에 하나 이상의 오류가 있습니다. 이 코드 블록은 filePath 위치에 있는 Parquet 파일을 DataFrame에 로드해야 하며, 이전에 수정된 파일만 로드해야 합니다. 2029-03-20 05:44:46. Spark는 아래 표시된 스키마에 따라 스키마를 적용해야 합니다. 오류를 찾으세요. 개요: 1.뿌리 2. |-- itemId: 정수(nullable = true) 3. |-- 속성: 배열(nullable = true) 4. | |-- 요소: 문자열(containsNull = true) 5. |-- 공급자: 문자열(nullable = true) 코드 블록: 1.스키마 = 구조체 유형([ 2. StructType("itemId", IntegerType(), True), 3. StructType("속성", ArrayType(StringType(), True), True), 4. StructType("공급업체", StringType(), True) 5.]) 6. 7.spark.read.options("수정됨", "2029-03-20T05:44:46").schema(스키마).load(파일 경로)
정답: D
설명 올바른 코드 블록: 스키마 = 구조체 유형([ StructField("itemId", IntegerType(), True), StructField("속성", ArrayType(StringType(), True), True), StructField("공급업체", StringType(), True) ]) spark.read.options(modifiedBefore="2029-03-20T05:44:46").schema(schema).parquet(filePath) 이 문제는 시험에서 접하게 될 문제보다 더 어렵습니다. 시험에서 이 문제 유형은 문제에서처럼 "하나 또는 여러 개"가 아닌, 단 하나의 오류만 지적하면 됩니다. 스키마 정의의 열이 잘못된 개체 유형을 사용하고, 수정 날짜 임계값이 잘못 지정되었으며, Spark에서 파일 형식을 식별할 수 없습니다. 맞습니다! 스키마 정의의 열은 StructField 타입을 사용해야 합니다. pyspark.sql.types에서 StructType 및 StructField와 같은 클래스를 사용하여 스키마를 구축하는 것은 Spark에서 스키마를 표현하는 여러 방법 중 하나입니다. StructType은 항상 StructField 목록을 포함합니다(아래 링크된 문서 참조). 따라서 질문에서처럼 StructType과 StructType을 중첩하는 것은 잘못된 것입니다. 수정 날짜 임계값은 options(modifiedBefore="2029-03-20T05:44:46")과 같은 키워드 인수로 지정해야 하며, 원래 코드 블록에서처럼 두 개의 연속된 비키워드 인수를 사용해서는 안 됩니다(아래 링크된 문서 참조). Spark는 파일 형식을 올바르게 식별할 수 없습니다. DataFrameReader.format()을 사용하거나 DataFrameReader.load()의 인수로 지정하거나, 예를 들어 DataFrameReader.parquet()를 직접 호출하여 지정해야 하기 때문입니다. 스키마의 열이 빈 값을 처리할 수 없으며 수정 날짜 임계값이 잘못 지정되었습니다. No. If StructField would be used for the columns instead of StructType (see above), the third argument specified whether the column is nullable. The original schema shows that columns should be nullable and this is specified correctly by the third argument being True in the schema in the code block. It is correct, however, that the modification date threshold is specified incorrectly (see above). The attributes array is specified incorrectly, Spark cannot identify the file format, and the syntax of the call to Spark's DataFrameReader is incorrect. Wrong. The attributes array is specified correctly, following the syntax for ArrayType (see linked documentation below). That Spark cannot identify the file format is correct, see correct answer above. In addition, the DataFrameReader is called correctly through the SparkSession spark. Columns in the schema definition use the wrong object type and the syntax of the call to Spark's DataFrameReader is incorrect. Incorrect, the object types in the schema definition are correct and syntax of the call to Spark's DataFrameReader is correct. The data type of the schema is incompatible with the schema() operator and the modification date threshold is specified incorrectly. False. The data type of the schema is StructType and an accepted data type for the DataFrameReader.schema() method. It is correct however that the modification date threshold is specified incorrectly (see correct answer above).