Skip to content

Commit

Permalink
nits to OPTIMIZE TABLE
Browse files Browse the repository at this point in the history
  • Loading branch information
drodrigues4 committed Jul 24, 2024
1 parent 4afb283 commit d09afcc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions drizzle-orm/src/singlestore-core/dialect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ export class SingleStoreDialect {
return sql`drop milestone ${milestone}${forSql}`;
}

buildOptimizeTable({ table }: SingleStoreOptimizeTableConfig): SQL {
return sql`optimize table ${table}`;
buildOptimizeTable({ table, arg, selection }: SingleStoreOptimizeTableConfig): SQL {
const warmBlobCacheForColumnSql = selection ?
sql`warm blob cache for column ${selection}`
: undefined;

return sql`optimize table ${table}${arg}${warmBlobCacheForColumnSql}`;
}

buildUpdateSet(table: SingleStoreTable, set: UpdateSet): SQL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import type {
} from '~/singlestore-core/session.ts';
import type { Query, SQL, SQLWrapper } from '~/sql/sql.ts';
import type { SingleStoreTable } from '../table.ts';
import type { SelectedFields } from './select.types.ts';
import type { OptimizeTableArgument } from './optimizeTable.types.ts';
import type { OptimizeTableArgument, SelectedColumns } from './optimizeTable.types.ts';

export type SingleStoreOptimizeTableWithout<
T extends AnySingleStoreOptimizeTableBase,
Expand Down Expand Up @@ -42,7 +41,7 @@ export type SingleStoreOptimizeTable<
export interface SingleStoreOptimizeTableConfig {
table: SingleStoreTable;
arg?: OptimizeTableArgument | undefined;
selection?: SelectedFields | undefined;
selection?: SelectedColumns | undefined;
}

export type SingleStoreOptimizeTablePrepare<T extends AnySingleStoreOptimizeTableBase> = PreparedQueryKind<
Expand Down Expand Up @@ -106,7 +105,7 @@ export class SingleStoreOptimizeTableBase<
}

// TODO(singlestore): docs
warmBlobCacheForColumn(selection: SelectedFields): SingleStoreOptimizeTableWithout<this, TDynamic, 'warmBlobCacheForColumn'> {
warmBlobCacheForColumn(...selection: SelectedColumns): SingleStoreOptimizeTableWithout<this, TDynamic, 'warmBlobCacheForColumn'> {
if (this.config.arg) {
throw new Error('Cannot call warmBlobCacheForColumn with an argument');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { SingleStoreColumn } from ".."
import type { ColumnBaseConfig, ColumnDataType } from "~/index"

export type OptimizeTableArgument =
| 'FULL'
| 'FLUSH'
| 'FIX_ALTER'
| 'INDEX'

export type SelectedColumns = [SingleStoreColumn<ColumnBaseConfig<ColumnDataType, string>, object>]

0 comments on commit d09afcc

Please sign in to comment.