構造一個 DataFrame 代表資料庫資料表,可透過 JDBC URL url存取。 如果指定了 column 或 predicates ,則平行地檢索資料表的分割。 若 column 同時指定 和 predicates ,則 column 優先。
語法
jdbc(url, table, column=None, lowerBound=None, upperBound=None,
numPartitions=None, predicates=None, properties=None)
參數
| 參數 | 類型 | 說明 |
|---|---|---|
url |
str | JDBC 表格的網址 jdbc:subprotocol:subname。 |
table |
str | 外部資料庫中資料表的名稱。 |
column |
力量,選用 | 用於分割的欄位(選項別名 partitionColumn )。 需要 lowerBound、 upperBound、 numPartitions。 |
lowerBound |
智力或力量,選擇性 | 分割時的 column 最小值。 當指定 column 時需要。 |
upperBound |
智力或力量,選擇性 | 分割時的最大 column 值。 當指定 column 時需要。 |
numPartitions |
int,可選 | 數據分割的數目。 當指定 column 時需要。 |
predicates |
清單,選用 | 一個子句表達式的列表 WHERE ,每個表達式定義了 的一個分割 DataFrame。 如果已指定 column,則會被忽略。 |
properties |
DICT,選擇性 | JDBC 連接參數,通常包含 'user' 和 'password'。 例如: {'user': 'SYSTEM', 'password': 'mypassword'} 。 |
退貨
DataFrame
Notes
避免在大型叢集上同時建立太多分割區,否則可能會讓外部資料庫系統當機。