通用 URI 接口
uri() 方法作为统一入口,它会自动检测源类型:
URI 语法参考
| 来源类型 | URI 格式 | 示例 |
|---|---|---|
| 本地文件 | path/to/file | data.csv, /abs/path/data.parquet |
| S3 | s3://bucket/path | s3://mybucket/data.parquet?nosign=true |
| GCS | gs://bucket/path | gs://mybucket/data.csv |
| Azure | az://container/path | az://mycontainer/data.parquet |
| HTTP/HTTPS | https://url | https://example.com/data.csv |
| MySQL | mysql://user:pass@host:port/db/table | mysql://root:pass@localhost:3306/mydb/users |
| PostgreSQL | postgresql://user:pass@host:port/db/table | postgresql://postgres:pass@localhost:5432/mydb/users |
| SQLite | sqlite:///path?table=name | sqlite:///data.db?table=users |
| ClickHouse | clickhouse://host:port/db/table | clickhouse://localhost:9000/default/hits |
File 数据源
from_file
| 参数 | 类型 | 默认值 | 说明 |
|---|---|---|---|
path | str | 必填 | 文件路径 (本地路径或 URL) |
format | str | None | 文件格式 (若为 None,则自动检测) |
compression | str | None | 压缩类型 (若为 None,则自动检测) |
兼容 Pandas 的读取函数
云存储
from_s3
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
url | str | 必填 | S3 URL (s3://bucket/path) |
access_key_id | str | None | AWS 访问密钥 ID |
secret_access_key | str | None | AWS 秘密访问密钥 |
format | str | None | 文件格式 (自动检测) |
from_gcs
from_azure
from_hdfs
from_url
数据库
from_mysql
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
host | str | required | MySQL 主机 |
database | str | required | 数据库名称 |
table | str | required | 表名称 |
user | str | required | 用户名 |
password | str | required | 密码 |
port | int | 3306 | 端口号 |
from_postgresql
from_clickhouse
from_mongodb
from_sqlite
数据湖
from_iceberg
from_delta
from_hudi
内存源
from_df / from_dataframe
DataFrame 构造函数
特殊数据源
from_numbers
from_random
run_sql
汇总表
| Method | 来源类型 | 示例 |
|---|---|---|
uri() | 通用 | DataStore.uri("s3://bucket/data.parquet") |
from_file() | 本地/远程文件 | DataStore.from_file("data.csv") |
read_csv() | CSV 文件 | pd.read_csv("data.csv") |
read_parquet() | Parquet 文件 | pd.read_parquet("data.parquet") |
from_s3() | 亚马逊 S3 | DataStore.from_s3("s3://bucket/path") |
from_gcs() | Google Cloud Storage | DataStore.from_gcs("gs://bucket/path") |
from_azure() | Azure Blob 存储 | DataStore.from_azure("az://container/path") |
from_hdfs() | HDFS | DataStore.from_hdfs("hdfs://host/path") |
from_url() | HTTP/HTTPS | DataStore.from_url("https://example.com/data.csv") |
from_mysql() | MySQL | DataStore.from_mysql(host, db, table, user, pass) |
from_postgresql() | PostgreSQL | DataStore.from_postgresql(host, db, table, user, pass) |
from_clickhouse() | ClickHouse | DataStore.from_clickhouse(host, db, table) |
from_mongodb() | MongoDB | DataStore.from_mongodb(uri, db, collection) |
from_sqlite() | SQLite | DataStore.from_sqlite("data.db", table) |
from_iceberg() | Apache Iceberg | DataStore.from_iceberg("/path/to/table") |
from_delta() | Delta Lake | DataStore.from_delta("/path/to/table") |
from_hudi() | Apache Hudi | DataStore.from_hudi("/path/to/table") |
from_df() | pandas DataFrame | DataStore.from_df(pandas_df) |
DataFrame() | 字典 / DataFrame | pd.DataFrame({'a': [1, 2, 3]}) |
from_numbers() | 连续数字 | DataStore.from_numbers(1000000) |
from_random() | 随机数据 | DataStore.from_random(rows=1000, columns=5) |
run_sql() | Raw SQL | DataStore.run_sql("SELECT * FROM ...") |