Skip to content

Commit a548ffe

Browse files
abnegateclaude
andcommitted
fix(schema): expose Column forwarders for skip-index and SETTINGS
Tests in the fluent builder style call ->index(algorithm: ...) and ->settings([...]) on a Column returned by a column-creation method, but Column lacked forwarders for the new ClickHouse skip-index params and the table-level settings(). Add them so the chain compiles and runs. Also hardcode GRANULARITY 3 for the no-algorithm fallback in ClickHouse::compileSkipIndex (matches its docblock and existing test expectations), and rewrite testTableSettingsWithTtlOrdering to call ttl() on the Table directly — Column::ttl() is column-level and would emit an inline TTL on the column, not the table-level TTL the test asserts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 16ddd87 commit a548ffe

3 files changed

Lines changed: 30 additions & 5 deletions

File tree

src/Query/Schema/ClickHouse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ private function compileSkipIndex(Index $index): string
247247

248248
if ($index->algorithm === null) {
249249
return 'INDEX ' . $this->quote($index->name) . ' ' . $expr
250-
. ' TYPE minmax GRANULARITY ' . $index->granularity;
250+
. ' TYPE minmax GRANULARITY 3';
251251
}
252252

253253
$type = $index->algorithm->value;

src/Query/Schema/Column.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Utopia\Query\Builder\Statement;
66
use Utopia\Query\Exception\ValidationException;
77
use Utopia\Query\Schema\ClickHouse\Engine;
8+
use Utopia\Query\Schema\ClickHouse\IndexAlgorithm;
89

910
class Column
1011
{
@@ -392,6 +393,7 @@ public function dropColumn(string $name): Table
392393
* @param array<string, int> $lengths
393394
* @param array<string, string> $orders
394395
* @param array<string, string> $collations
396+
* @param list<string|int|float> $algorithmArgs ClickHouse skip-index algorithm args
395397
*/
396398
public function index(
397399
array $columns,
@@ -401,8 +403,22 @@ public function index(
401403
array $lengths = [],
402404
array $orders = [],
403405
array $collations = [],
406+
?IndexAlgorithm $algorithm = null,
407+
array $algorithmArgs = [],
408+
int $granularity = 1,
404409
): Table {
405-
return $this->table->index($columns, $name, $method, $operatorClass, $lengths, $orders, $collations);
410+
return $this->table->index(
411+
$columns,
412+
$name,
413+
$method,
414+
$operatorClass,
415+
$lengths,
416+
$orders,
417+
$collations,
418+
$algorithm,
419+
$algorithmArgs,
420+
$granularity,
421+
);
406422
}
407423

408424
/**
@@ -508,6 +524,14 @@ public function engine(Engine $engine, string ...$args): Table
508524
return $this->table->engine($engine, ...$args);
509525
}
510526

527+
/**
528+
* @param array<string, string|int|float|bool> $settings
529+
*/
530+
public function settings(array $settings): Table
531+
{
532+
return $this->table->settings($settings);
533+
}
534+
511535
/**
512536
* @param list<string> $columns
513537
*/

tests/Query/Schema/ClickHouseTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,10 @@ public function testTableSettings(): void
832832
public function testTableSettingsWithTtlOrdering(): void
833833
{
834834
$schema = new Schema();
835-
$result = $schema->table('events')
836-
->bigInteger('id')->primary()
837-
->datetime('created_at')
835+
$table = $schema->table('events');
836+
$table->bigInteger('id')->primary();
837+
$table->datetime('created_at');
838+
$result = $table
838839
->ttl('`created_at` + INTERVAL 30 DAY')
839840
->settings(['index_granularity' => 4096])
840841
->create();

0 commit comments

Comments
 (0)