Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MySQL ADBC driver ignores the target schema when creating an ingest table

未关闭
#258 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
mysql, python
领域
database

调研方向

The workaround lives in xarray_sql/backends/adbc.py, in _default_database, which switches the connection's default database for MySQL and MariaDB. The root bug is in the upstream adbc-drivers/mysql driver, so the first step is to reproduce it with the snippet in the issue and file the upstream report. Done here means the upstream issue exists and test_mysql_mixed_dimensions_register_in_a_database passes with XARRAY_SQL_TEST_MYSQL_URI set; removing the workaround waits for a fixed driver release.

由索引模型根据 Issue 内容生成。

描述

Summary

The ADBC Driver Foundry's MySQL driver (0.6.1, the latest release at the time of writing) ignores the target schema when it creates the table for an ingest. Given db_schema_name, it creates the table in the connection's default database, then inserts into the target database, so the ingest fails.

#255 works around this in the ADBC adapter. This issue tracks the workaround until the driver is fixed.

Reproduction

MySQL 8.4.11, adbc-driver-manager 1.12.0, MySQL driver 0.6.1 (dbc install mysql):

import pyarrow as pa
from adbc_driver_manager import dbapi

con = dbapi.connect(driver="mysql", db_kwargs={"uri": "mysql://[email protected]:3306/xql"})
with con.cursor() as cur:
    cur.execute("CREATE DATABASE IF NOT EXISTS era5")
    cur.adbc_ingest("surface", pa.table({"x": [1.0]}), mode="create", db_schema_name="era5")
  • Expected: a table era5.surface holding one row.

  • Actual:

    ProgrammingError: NOT_FOUND: [MySQL] failed to prepare batch insert statement:
    Error 1146 (42S02): Table 'era5.surface' doesn't exist.
    

    The table was created as xql.surface, in the connection's default database, according to information_schema.tables.

Workaround in xarray-sql

For MySQL and MariaDB, xarray_sql/backends/adbc.py doesn't pass db_schema_name at all. Instead, _default_database makes the target database the connection's default (USE era5) for the duration of the ingest, then restores the previous default. MySQL can't unset a default database, so a connection that had no default keeps the target afterwards.

This is how mixed-dimension Datasets register as era5.<group> on MySQL. test_mysql_mixed_dimensions_register_in_a_database covers it; the test runs when XARRAY_SQL_TEST_MYSQL_URI is set.

Next steps

  • Report upstream at adbc-drivers/mysql (no existing issue covered it at the time of writing).
  • Once a fixed driver is released, remove _default_database and pass db_schema_name through on MySQL, as on every other database.

🤖 Generated with Claude Code

主要语言
Python
星标
142
派生
19
平均合并
1 天 9 小时
30 天内合并 PR
9

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

xqlsystems/xarray-sql 的其他 Issue

查看 xqlsystems/xarray-sql 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。