을 얻으려고 깊은 이해의 방법 spark 작품과 연결된 pyspark cli(2.4.0). 내가 찾는 사이의 차이를 사용하여 limit(n).show()
고 show(n)
. 나는 점점 두 개의 매우 다양한 성능 시간을 위한 두 개의 매우 유사한 쿼리를 처리합니다. 아래의 명령을 내가 달렸다. 마루 파일에서 참조 코드는 아래에는 약 50 열고 over50 기가 바이트의 크기에 원격 HDFS.
# Create dataframe
>>> df = sqlContext.read.parquet('hdfs://hdfs.host/path/to.parquet') ↵
# Create test1 dataframe
>>> test1 = df.select('test_col') ↵
>>> test1.schema ↵
StructType(List(StructField(test_col,ArrayType(LongType,true),true)))
>>> test1.explain() ↵
== Physical Plan ==
*(1) Project [test_col#40]
+- *(1) FileScan parquet [test_col#40]
Batched: false,
Format: Parquet,
Location: InMemoryFileIndex[hdfs://hdfs.host/path/to.parquet],
PartitionCount: 25,
PartitionFilters: [],
PushedFilters: [],
ReadSchema: struct<test_col:array<bigint>>
# Create test2 dataframe
>>> test2 = df.select('test_col').limit(5) ↵
>>> test2.schema ↵
StructType(List(StructField(test_col,ArrayType(LongType,true),true)))
>>> test2.explain() ↵
== Physical Plan ==
CollectLimit 5
+- *(1) Project [test_col#40]
+- *(1) FileScan parquet [test_col#40]
Batched: false,
Format: Parquet,
Location: InMemoryFileIndex[hdfs://hdfs.host/path/to.parquet],
PartitionCount: 25,
PartitionFilters: [],
PushedFilters: [],
ReadSchema: struct<test_col:array<bigint>>
통합 물리 계획은 거의 동일한 모두에 대한 test1
고 test2
. 유일한 예외가 test2 의 계획을 시작으로"CollectLimit5"입니다. 후에 설정이 나는 달 test1.show(5)
고 test2.show(5)
. 1 테스트 결과를 즉시. 테스트 보 2 진행 표시줄로 2010 작업에 걸렸다가 20 분이 완료(나리타 국제공항까지 실행)
질문 왜 테스트 2(제한)을 수행하도록 가난하게 비교하여 테스트하 1(없이 제한)? 데이터 세트 및 그 결과로 설정이 동일하고 실제 계획은 거의 동일합니다.