Skip to content

Commit 2deae10

Browse files
fix: align templates and remove extra indentation (#3159)
1 parent bff31a0 commit 2deae10

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/containers/Tenant/utils/schemaQueryTemplates.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ function toLF(str: string) {
2424
return str.replace(/\r\n?/g, '\n');
2525
}
2626

27-
function indentBlock(str: string, pad = ' ') {
28-
return str.replace(/^/gm, pad);
29-
}
30-
3127
export const createTableTemplate = (params?: SchemaQueryParams) => {
3228
const tableName = params?.relativePath
3329
? `\`${normalizeParameter(params.relativePath)}/my_row_table\``
@@ -333,8 +329,10 @@ export const createStreamingQueryTemplate = (params?: SchemaQueryParams) => {
333329
RUN = TRUE -- Run the query after creation
334330
) AS
335331
DO BEGIN
336-
INSERT INTO \${2:<external data source>}.\${3:<sink topic>}
337-
SELECT * FROM \${2:<external data source>}.\${4:<source topic>};
332+
333+
INSERT INTO \${2:<external data source>}.\${3:<sink topic>}
334+
SELECT * FROM \${2:<external data source>}.\${4:<source topic>};
335+
338336
END DO;`;
339337
};
340338

@@ -360,14 +358,14 @@ export const alterStreamingQueryText = (params?: SchemaQueryParams) => {
360358
queryText = stripIndentByFirstLine(queryText);
361359
queryText = normalizeParameter(queryText);
362360

363-
const bodyQueryText = queryText
364-
? indentBlock(queryText)
365-
: indentBlock('${2:<streaming_query_text>}');
361+
const bodyQueryText = queryText ? queryText : '${2:<streaming_query_text>}';
366362
return `ALTER STREAMING QUERY ${streamingQueryName} SET (
367363
FORCE = TRUE, -- Allow to drop last query checkpoint if query state can't be loaded
368364
) AS
369365
DO BEGIN
366+
370367
${bodyQueryText}
368+
371369
END DO;`;
372370
};
373371

0 commit comments

Comments
 (0)