Repository navigation
Add integration tests for AI functions - #103053
Merged
george-larionov merged 6 commits intoJun 11, 2026
Merged
Conversation
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
2 times, most recently
from
April 18, 2026 03:49
3ee7788 to
6629fdc
Compare
1 task done
1 task done
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
from
May 15, 2026 10:11
6629fdc to
f4bc442
Compare
Contributor
|
Workflow [PR], commit [8607433] Summary: ❌
AI ReviewSummaryThis PR adds a dedicated Missing context / blind spots
Final VerdictStatus: ✅ Approve |
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
from
May 15, 2026 16:00
f4bc442 to
136a172
Compare
1 task
Member
|
This was fixed by #105146. Let's update the branch. |
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
2 times, most recently
from
May 21, 2026 17:09
69d1161 to
e260eec
Compare
george-larionov
marked this pull request as ready for review
May 23, 2026 15:50
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
from
May 29, 2026 22:13
e260eec to
8902e44
Compare
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
from
June 9, 2026 19:00
8902e44 to
a0982c8
Compare
george-larionov
enabled auto-merge
June 9, 2026 22:01
Adds integration tests with a mock OpenAI-compatible HTTP server for `aiGenerateContent`, `aiClassify`, `aiExtract`, and `aiTranslate`. The mock detects `response_format` in requests and returns structured JSON matching the schema (for `aiClassify` and `aiExtract`), or echoes the user message as plain text (for `aiTranslate` and `aiGenerateContent`). Coverage per function: - Basic execution, multi-row processing, ProfileEvents, NULL handling - `aiClassify`: JSON schema with enum constraint, `postProcessResponse` extraction of category field - `aiExtract`: simple instruction mode (single result field) and JSON schema mode (multi-field extraction) - `aiTranslate`: plain text response, optional instructions argument - `aiGenerateContent`: error throw/graceful paths Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Extends the existing mock OpenAI-compatible HTTP server with embedding endpoints (`/v1/embeddings`, plus malformed-response and error variants) and adds twelve `aiEmbed` cases covering: native and explicit `dimensions`, multi-row batching into a single HTTP call, `ai_function_embedding_max_batch_size` splitting inputs across calls, `NULL` / empty inputs mapping to `[]` without a request, error throw vs. graceful fallback, provider response validation (duplicate `index`, wrong cardinality), and `ai_function_max_input_tokens_per_query` quota truncation. Also updates the pre-existing `aiGenerateContent` call sites to use the function's registered name `aiGenerate` so those tests still pass after rebasing onto `feature/ai-embeddings`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Pre-filtered `NULL`/empty inputs no longer count toward `AIRowsSkipped`; only quota- or error-cut rows do, matching the documented contract. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Bump mock port to 18123, drop unnecessary sentinel UUIDs in `test_translate_with_instructions`, and remove a redundant `TRUNCATE`/`INSERT` from `test_generate_content_basic`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Update embed-validation tests to expect MALFORMED_AI_PROVIDER_RESPONSE (introduced upstream) instead of RECEIVED_ERROR_FROM_REMOTE_IO_SERVER, and add coverage for optional api_key in AI named collections: verify the Authorization header is omitted when no key is set and forwarded as a Bearer token when present. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
george-larionov
force-pushed
the
feature/ai-text-functions-integration-tests
branch
from
June 10, 2026 20:59
a0982c8 to
8607433
Compare
Contributor
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 467 line(s), 60 function(s) across 129 file(s) · Details Top files
|
Member
Author
|
The failing test is flaky and unrelated: #106651 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds integration tests with a mock OpenAI-compatible HTTP server for aiGenerate, aiClassify, aiExtract, aiTranslate, and aiEmbed.
For chat completions, the mock detects response_format in requests and returns structured JSON matching the schema (for aiClassify and aiExtract), or echoes the user message as plain text (for aiTranslate and aiGenerate). For embeddings, the
mock returns one deterministic float vector per input, honoring the optional dimensions argument and reporting prompt_tokens so quota and token-accounting paths are exercised.
Coverage per function:
rejection of malformed provider responses (duplicate index, wrong cardinality), and ai_function_max_input_tokens_per_query quota truncation
To be merged after #102922
Changelog category (leave one):
Note
Low Risk
Low risk: only adds integration-test code and a standalone mock server, with no production logic changes.
Overview
Adds a new
tests/integration/test_ai_functionssuite that spins up a ClickHouse instance plus a local OpenAI-compatible mock server, then validatesaiGenerate,aiClassify,aiExtract,aiTranslate, andaiEmbedacross basic, multi-row, NULL/empty-input, and ProfileEvents/token-accounting scenarios.The mock server implements chat-completions and embeddings endpoints (including structured
response_formatJSON-schema replies) plus dedicated failure/malformed-response routes to test error handling, embedding batching (ai_function_embedding_max_batch_size), and quota-cut behavior (ai_function_max_input_tokens_per_query).Reviewed by Cursor Bugbot for commit e260eec. Bugbot is set up for automated code reviews on this repo. Configure here.
Version info
26.6.1.681