Skip to content

Feature/pubsub#127

Merged
jamals86 merged 6 commits intomainfrom
feature/pubsub
Feb 7, 2026
Merged

Feature/pubsub#127
jamals86 merged 6 commits intomainfrom
feature/pubsub

Conversation

@jamals86
Copy link
Copy Markdown
Collaborator

@jamals86 jamals86 commented Feb 7, 2026

No description provided.

Add a new examples/chat-with-ai Next.js app demonstrating a standalone AI processor service with kalam-link SDK (event-driven topic consumption). Include project files, setup scripts, schema, README and ARCHITECTURE docs, Next config and tests.

Introduce e2e-tests feature gating for backend/cli integration tests and register multiple CLI tests that require a full server instance. Update API consume logic to prefer consumer group committed offsets (resume from last_acked + 1) and only fall back to configured start positions when no committed offset exists. Fix manifest tests to use realistic millisecond timestamps and adjust expectations. Minor cleanups: remove unused imports in raft and topic_publisher tests and add/adjust TypeScript SDK client files and related build config to support WASM/TS usage.
Add support for tracking the user who produced a topic message end-to-end. Introduces a Username newtype (Rust) / branded string (TS) and includes username/user_id on topic messages; TopicMessage models get user_id and a new constructor. TopicPublisher/Notification now accept and forward an optional user_id, the API consume handler resolves user_id -> username and includes it in responses, and the wasm client surfaces username. TypeScript SDK ConsumeContext now carries username and message (handler signature adjusted), and examples/tests updated to use ctx.username and ctx.message. Also updated Notes.md to mention passing userid option.
Implement service-side impersonation and related plumbing across the stack.

Key changes:
- API: parse and accept EXECUTE AS USER 'name' (sql wrapped in parentheses) in /v1/api/sql; validate and resolve target user via SqlImpersonationService; substitute execution SQL and propagate effective user for execution and results. Added unit tests for parsing and username resolution.
- Execution: propagate execute_as_user into executor helpers; create ExecutionContext::with_effective_identity to run SQL as another user; SqlExecutor uses the effective context.
- Responses: add as_user field to QueryResult and with_as_user helper; results now include the effective username for each statement.
- Auth: prefer Authorization: Bearer header but fall back to auth cookie via extract_bearer_or_cookie_token; include username when constructing AuthSession extractor.
- SQL runtime: register CURRENT_USER(), CURRENT_USER_ID(), and CURRENT_ROLE() UDFs and ensure ExecutionContext registers them with actual identity; DataFusion session factory registers no-op defaults.
- Commons: introduce parse_string_as_scalar to coerce string literals to typed ScalarValue for Parquet comparisons; add Username alias exports.
- Misc: small README/docs additions (impersonation + topic examples), UI and CLI test additions, many tests and helpers to support the new behavior.

These changes enable wrapping a single SQL statement with EXECUTE AS USER to run statements as a specified user while preserving auditing, result metadata, and authorization checks.
Large repository-wide refactor: reorganized SQL executor handlers (removed legacy DML handler files, updated handler registry, executor utils and parameter validation), consolidated table utilities (added datafusion_dml and other utils), and improved schema registry/manifest flush logic. Also updated auth handlers, JWT/provider code, rate limiter/token bucket and file download support; many CLI, UI and test files adjusted to match the changes. Added TypeScript SDK file_ref.ts and a batch_compile_output_native_dml.txt artifact. Overall changes aim to centralize DML handling, improve schema/manifest management and align tests with the refactor.
Large refactor and fixes across SQL/function/runtime code:

- Rename and standardize SQL UDFs: context functions renamed to kdb_* (KDB_CURRENT_USER, KDB_CURRENT_USER_ID, KDB_CURRENT_ROLE) and id/generator UDFs lowercased (snowflake_id, ulid, uuid_v7). Tests updated to use new function names and sessions now use a DataFusionSessionFactory that centrally registers custom functions.
- ExecutionContext: removed per-session UDF registrations (moved to central session factory) to avoid duplication.
- SqlExecutor: add parameterized DML optimization with a plan cache and placeholder binding to reuse template plans for INSERT/UPDATE/DELETE; includes robust fallback when table providers are missing and reload logic.
- Namespace/topic DDL fixes: CREATE NAMESPACE now returns AlreadyExists unless IF NOT EXISTS is set (and added tests); DROP NAMESPACE now deterministically drops all tables first (avoids stale metadata failures); CREATE TOPIC requires namespace-qualified names and verifies namespace existence, with validation and tests added.
- Arrow/Schema: UUID mapping changed to FixedSizeBinary(16) to represent 16-byte RFC4122 binary UUIDs.
- Indexed store: iterator handling fixes and optimized batch-prefix existence checks (use per-prefix point checks when no common prefix, improved iterator usage).
- Misc: small .gitignore and Notes.md updates and various test/example tweaks to reflect above changes.

These changes improve correctness (DDL edge-cases), performance (cached DML plans), and consistency of SQL UDF naming and registration.
@jamals86 jamals86 merged commit c0f33b6 into main Feb 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant