fix(datasource): SparkConnector.table_simple_info raises TypeError on every call - #3213
fix(datasource): SparkConnector.table_simple_info raises TypeError on every call#3213Anai-Guo wants to merge 1 commit into
Conversation
…table_simple_info SparkConnector.get_fields is declared as get_fields(self, table_name: str), matching the BaseConnector contract, but table_simple_info called it with no arguments, so every call raised TypeError.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📜 Recent review details🧰 Additional context used📓 Path-based instructions (2)此 package 包含数据库 connector、RAG 实现、storage backend、model adapter⚙️ CodeRabbit configuration file Files:
Use Python 3.10 or newer for project development.📄 CodeRabbit inference engine (CONTRIBUTING.md) Files:
🔇 Additional comments (1)
📝 WalkthroughPurpose
Scope
Risks
VerificationNo targeted test was added or reported. Add a regression test for Run the package tests and a targeted lint check: python -m pytest packages/dbgpt-ext/tests
ruff check packages/dbgpt-ext/src/dbgpt_ext/datasource/conn_spark.pyWalkthrough
ChangesSpark connector
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to The change fixes Spark table metadata calls that previously failed immediately by passing the existing table name to the required method, restoring the intended summary response with no actionable merge-blocking risk remaining. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Description checkExplanation The description clearly explains the problem, root cause, fix, scope, and reproducible verification. It omits the template's Snapshots and Checklist sections and does not explicitly state dependencies, but the required change context and testing details are complete. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
SparkConnector.table_simple_info()raisesTypeErroron every call.SparkConnector.get_fieldsis declared with a requiredtable_name, matching theBaseConnector.get_fields(self, table_name: str)contract(
packages/dbgpt-core/src/dbgpt/datasource/base.py:203):but
table_simple_infocalls it with no arguments(
packages/dbgpt-ext/src/dbgpt_ext/datasource/conn_spark.py:171):self.get_fields()resolves toSparkConnector.get_fields, which needstable_name, so the f-string never gets evaluated:Reachability
table_simple_info()is called generically on whatever connector the datasourceresolves to, so a Spark datasource hits this:
packages/dbgpt-serve/src/dbgpt_serve/agent/resource/datasource.py:170—
table_infos = conn.table_simple_info(), the fallback path whenget_db_summaryreturns nothing.packages/dbgpt-serve/src/dbgpt_serve/evaluate/service/fetchdata/benchmark_data_manager.py:1009—
return list(self._connector.table_simple_info())Fix
Pass the table name the method already has in hand.
__init__setsself.table_name = "temp", and the same attribute is already interpolated on thepreceding part of that very f-string.
SparkConnector.get_fieldscurrently ignorestable_name(it has an explicitTODO: Support table_nameand readsself.df.dtypes), so this changes no output— it only lets the call succeed. When that TODO is implemented, the call site is
already passing the right thing.
Verification
No Spark cluster is needed to show this. The two method bodies were extracted from
the real file with
astand executed against a stub DataFrame:The unpatched run reproduces the exact
TypeError; the patched run returns theintended summary string.
Scope
Deliberately limited to the one broken call. Not changed here:
get_fieldsstill ignorestable_name— that is the pre-existingTODO, andimplementing it is a separate change.
SparkConnector.table_simple_inforeturns astrwhile the RDBMS/Neo4j/TuGraphimplementations return a sequence. That inconsistency is real but predates this
bug and is out of scope for a crash fix.
🤖 Generated with Claude Code