partitionColumnํํฐ์ ์ ๊ฒฐ์ ํ๋ ๋ฐ ์ฌ์ฉํด์ผ ํ๋ ์ด
lowerBound๊ฐ์ ธ์ฌ ๊ฐ์ ๋ฒ์ ๋ฅผ upperBound๊ฒฐ์ ํฉ๋๋ค.
์ ์ฒด ๋ฐ์ดํฐ ์ธํธ๋ ๋ค์ ์ฟผ๋ฆฌ์ ํด๋นํ๋ ํ์ ์ฌ์ฉ
SELECT * FROM table WHERE partitionColumn BETWEEN lowerBound AND upperBound
- lowerBound: 0
- upperBound: 1000
- numPartitions: 10
Stride๋ 100์ด๊ณ ํํฐ์ ์ ๋ค์ ์ฟผ๋ฆฌ์ ํด๋นํฉ๋๋ค.
- SELECT * FROM table WHERE partitionColumn BETWEEN 0 AND 100
- SELECT * FROM table WHERE partitionColumn BETWEEN 100 AND 200
- SELECT * FROM table WHERE partitionColumn BETWEEN 900 AND 1000
upperBound / numPartitions - lowerBound / numPartitions
upperbound ๊ตฌํ๋ ๋ฒ
query = f"""SELECT MIN({partitionColumn}), MAX({partitionColumn}) FROM ({db.table})"""
min_max_df = spark.read \
.format("jdbc") \
.option("url", "jdbc:postgresql:postgres") \
.option("dbtable", "db.table") \
.option("user", "user")\
.option("password", "pass") \
.option("query", query) \
.load()
lowerBound, upperBound = min_max_df.collect()[0]