Skip to content

Commit d8ec6de

Browse files
fix: resolve PartitionSpec strategy mapping in CreateStmt method
- Fixed partspec transformation to correctly map PG15 strategy strings to PG16 enum values - Handles partspec as plain object in CreateStmt rather than separate wrapped node method - Improves test pass rate from 180/258 to 183/258 (70.9% success rate) - Resolves pretty-create_table.test.ts failures with proper strategy enum conversion Co-Authored-By: Dan Lynch <[email protected]>
1 parent 9b7bb10 commit d8ec6de

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/transform/src/transformers/v15-to-v16.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,25 @@ export class V15ToV16Transformer {
922922
}
923923

924924
if (node.partspec !== undefined) {
925-
result.partspec = this.transform(node.partspec as any, context);
925+
// Handle partspec transformation directly since it's a plain object, not a wrapped node
926+
const partspec: any = { ...node.partspec };
927+
928+
if (partspec.strategy !== undefined) {
929+
const strategyMap: Record<string, string> = {
930+
'range': 'PARTITION_STRATEGY_RANGE',
931+
'list': 'PARTITION_STRATEGY_LIST',
932+
'hash': 'PARTITION_STRATEGY_HASH'
933+
};
934+
partspec.strategy = strategyMap[partspec.strategy] || partspec.strategy;
935+
}
936+
937+
if (partspec.partParams !== undefined) {
938+
partspec.partParams = Array.isArray(partspec.partParams)
939+
? partspec.partParams.map((item: any) => this.transform(item as any, context))
940+
: this.transform(partspec.partParams as any, context);
941+
}
942+
943+
result.partspec = partspec;
926944
}
927945

928946
if (node.ofTypename !== undefined) {
@@ -2222,6 +2240,7 @@ export class V15ToV16Transformer {
22222240
return { PartitionCmd: result };
22232241
}
22242242

2243+
22252244
JoinExpr(node: PG15.JoinExpr, context: TransformerContext): any {
22262245
const result: any = {};
22272246

0 commit comments

Comments
 (0)