Daft sql查询数据库处理简单说明
此sql 不是Daft 对于dataframe 的sql 查询处理,而是对于database 数据源的查询处理,以下是一些简单数名
简单说明
- 支持20+ 数据库方言,基于了sqlGlot,当然处理部分有基于connector-x的以及sqlalchemy的,默认使用connector-x 对于不支持的会进行fall back 到sqlalchemy,我们也可以指定明确使用的数据connection
- 执行并行以及分布式读,当然这个是Daft 的标配能力
- 支持数据过滤,select,limit,where
- 目前对于db的写入暂时是不支持的,同时对于ADBC的支持也在规划中
Daft 对于使用connector-x以及sqlalchemy的判断
实际上就是内部支持db 类型的判断,代码如下
def execute_sql_query(self, sql: str) -> pa.Table:
if self._should_use_connectorx():
return self._execute_sql_query_with_connectorx(sql)
else:
return self._execute_sql_query_with_sqlalchemy(sql)
_should_use_connectorx 的处理
def _should_use_connectorx(self) -> bool:
# Supported DBs extracted from here https://github.com/sfu-db/connector-x/tree/7b3147436b7e20b96691348143d605e2249d6119?tab=readme-ov-file#sources
connectorx_supported_dbs = {
"postgres",
"postgresql",
"mysql",
"mssql",
"oracle",
"bigquery",
"sqlite",
"clickhouse",
"redshift",
}
if isinstance(self.conn, str):
if self.dialect in connectorx_supported_dbs and self.driver == "":
return True
return False
说明
尽管Daft 对于数据的查询会有使用到connector-x以及sqlalchemy,但是Daft 为了提升内部的并发使用了类似connector-x 的查询分片以及统计能力,提升系统的性能
参考资料
daft/sql/sql_connection.py
daft/sql/sql_scan.py
https://www.getdaft.io/projects/docs/en/stable/user_guide/integrations/sql.html
https://sqlglot.com/sqlglot.html
https://github.com/tobymao/sqlglot
https://docs.sqlalchemy.org/en/20/orm/quickstart.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
2024-02-03 dremio 官方一篇关于使用了到的技术进行对象存储查询加速的博客
2024-02-03 dremio 服务暴露的一些端口
2024-02-03 dremio LivenessService 服务简单说明
2024-02-03 dbt_artifacts 一个很不错的dbt模型元数据扩展
2024-02-03 dremio cluster docker-compose 运行
2024-02-03 elementary 面向对象分析师的开源数据可观测工具
2022-02-03 让自己的npm包支持npm WARN deprecated