Skip to content

Commit 9617e56

Browse files
committed
fix
1 parent 5b1e2f1 commit 9617e56

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

packages/cubejs-query-orchestrator/src/orchestrator/QueryCache.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,14 @@ export class QueryCache {
436436
query = QueryCache.replaceAll(`${tableName}${suffix}`, usageTargetName, query);
437437
}
438438
}
439-
// Then replace base table name for any remaining references
440-
return QueryCache.replaceAll(tableName, targetTableName, query);
439+
// Replace base table name only when there are no usage-specific replacements.
440+
// When usageTargetTableNames is present, all SQL references already use __usage_N suffixes
441+
// and the base replacement would incorrectly match inside already-replaced target names
442+
// (e.g. turning "preagg20200101_hash" into "preagg20200101_hash20200101_hash").
443+
if (!usageTargetTableNames || Object.keys(usageTargetTableNames).length === 0) {
444+
return QueryCache.replaceAll(tableName, targetTableName, query);
445+
}
446+
return query;
441447
},
442448
keyQuery
443449
);

0 commit comments

Comments
 (0)