Skip to content

refactor(query): phase 1 of removing global service lookups#19638

Open
forsaken628 wants to merge 3 commits intodatabendlabs:mainfrom
forsaken628:globalinstance-core
Open

refactor(query): phase 1 of removing global service lookups#19638
forsaken628 wants to merge 3 commits intodatabendlabs:mainfrom
forsaken628:globalinstance-core

Conversation

@forsaken628
Copy link
Copy Markdown
Collaborator

@forsaken628 forsaken628 commented Mar 30, 2026

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

This PR is the first phase of removing global variables and global singleton lookups from the query layer.

In this phase, the focus is on introducing context-bound service access and migrating a low-risk subset of callsites away from direct global reads. The branch adds a generic
service registry/provider abstraction, makes session/query/table contexts able to expose registered services, and starts switching callers from GlobalInstance / ::instance()
style access to context-based lookup.

Key changes:

  • introduce a reusable service access abstraction in common/base
  • make SessionManager own default services and inject them into SessionContext
  • allow QueryContext and TableContext callsites to resolve services from the current execution context
  • migrate a first batch of low-risk callsites in query service, system tables, hooks, and table functions
  • update test contexts and related tests to work with context-bound service resolution

Scope of phase 1:

  • infrastructure and callsite migration only
  • keeps behavior changes minimal
  • does not attempt to remove all globals in one step
  • leaves higher-risk initialization and lifecycle refactors for follow-up phases

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Mar 30, 2026
@forsaken628 forsaken628 requested a review from sundy-li March 30, 2026 14:50
@forsaken628 forsaken628 marked this pull request as ready for review March 30, 2026 14:50
@forsaken628 forsaken628 force-pushed the globalinstance-core branch from 070ae73 to 0e237e2 Compare April 1, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-refactor this PR changes the code base without new features or bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant