From bcdae52470f98ac60de3d00e2547c9b420ecab62 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 8 Nov 2023 21:09:05 +0000 Subject: [PATCH] Revert "Add backticks and remove ckpt for manual refresh in acceleration flyout (#183) (#185)" This reverts commit f96c5d9d6e94052666a7b9a96dfba7401603e4c8. --- .../__tests__/query_builder.test.tsx | 7 --- .../visual_editors/query_builder.tsx | 36 +++++++--------- test/mocks/accelerationMock.ts | 43 +++++++------------ 3 files changed, 31 insertions(+), 55 deletions(-) diff --git a/public/components/acceleration/visual_editors/__tests__/query_builder.test.tsx b/public/components/acceleration/visual_editors/__tests__/query_builder.test.tsx index be39d151..44797479 100644 --- a/public/components/acceleration/visual_editors/__tests__/query_builder.test.tsx +++ b/public/components/acceleration/visual_editors/__tests__/query_builder.test.tsx @@ -13,13 +13,11 @@ import { indexOptionsMock3, indexOptionsMock4, indexOptionsMock5, - indexOptionsMock6, indexOptionsMockResult1, indexOptionsMockResult2, indexOptionsMockResult3, indexOptionsMockResult4, indexOptionsMockResult5, - indexOptionsMockResult6, materializedViewBuilderMock1, materializedViewBuilderMock2, materializedViewBuilderMockResult1, @@ -62,11 +60,6 @@ describe('buildIndexOptions', () => { expect(indexOptions).toEqual(indexOptionsMockResult5); }); - it('should build index options with manual refresh and checkpoint', () => { - const indexOptions = buildIndexOptions(indexOptionsMock6); - expect(indexOptions).toEqual(indexOptionsMockResult6); - }); - describe('skippingIndexQueryBuilder', () => { it('should build skipping index query as expected with interval refresh', () => { const result = skippingIndexQueryBuilder(skippingIndexBuilderMock1); diff --git a/public/components/acceleration/visual_editors/query_builder.tsx b/public/components/acceleration/visual_editors/query_builder.tsx index c395d9fc..e299f52e 100644 --- a/public/components/acceleration/visual_editors/query_builder.tsx +++ b/public/components/acceleration/visual_editors/query_builder.tsx @@ -46,7 +46,7 @@ export const buildIndexOptions = (accelerationformData: CreateAccelerationForm) ); } - if (refreshType !== 'manual' && checkpointLocation) { + if (checkpointLocation) { // Add checkpoint location option indexOptions.push(`checkpoint_location = '${checkpointLocation}'`); } @@ -58,7 +58,7 @@ export const buildIndexOptions = (accelerationformData: CreateAccelerationForm) /* Add skipping index columns to query */ const buildSkippingIndexColumns = (skippingIndexQueryData: SkippingIndexRowType[]) => { return skippingIndexQueryData - .map((n) => ` \`${n.fieldName}\` ${n.accelerationMethod}`) + .map((n) => ` ${n.fieldName} ${n.accelerationMethod}`) .join(', \n'); }; @@ -68,9 +68,9 @@ const buildSkippingIndexColumns = (skippingIndexQueryData: SkippingIndexRowType[ * * CREATE SKIPPING INDEX * ON datasource.database.table ( - * `field1` VALUE_SET, - * `field2` PARTITION, - * `field3` MIN_MAX, + * field1 VALUE_SET, + * field2 PARTITION, + * field3 MIN_MAX, * ) WITH ( * auto_refresh = true, * refresh_interval = '1 minute', @@ -91,7 +91,7 @@ ${buildSkippingIndexColumns(skippingIndexQueryData)} /* Add covering index columns to query */ const buildCoveringIndexColumns = (coveringIndexQueryData: string[]) => { - return coveringIndexQueryData.map((field) => ` \`${field}\``).join(', \n'); + return coveringIndexQueryData.map((field) => ` ${field}`).join(', \n'); }; /* @@ -100,9 +100,9 @@ const buildCoveringIndexColumns = (coveringIndexQueryData: string[]) => { * * CREATE INDEX index_name * ON datasource.database.table ( - * `field1`, - * `field2`, - * `field3`, + * field1, + * field2, + * field3, * ) WITH ( * auto_refresh = true, * refresh_interval = '1 minute', @@ -127,16 +127,12 @@ ${buildCoveringIndexColumns(coveringIndexQueryData)} return codeQuery; }; -const buildMaterializedViewColumnName = (columnName: string) => { - return columnName === '*' ? columnName : `\`${columnName}\``; -}; - const buildMaterializedViewColumns = (columnsValues: MaterializedViewColumn[]) => { return columnsValues .map( (column) => - ` ${column.functionName}(${buildMaterializedViewColumnName(column.functionParam)})${ - column.fieldAlias ? ` AS \`${column.fieldAlias}\`` : `` + ` ${column.functionName}(${column.functionParam})${ + column.fieldAlias ? ` AS ${column.fieldAlias}` : `` }` ) .join(', \n'); @@ -145,7 +141,7 @@ const buildMaterializedViewColumns = (columnsValues: MaterializedViewColumn[]) = /* Build group by tumble values */ const buildTumbleValue = (GroupByTumbleValue: GroupByTumbleType) => { const { timeField, tumbleWindow, tumbleInterval } = GroupByTumbleValue; - return `(\`${timeField}\`, '${tumbleWindow} ${tumbleInterval}${pluralizeTime(tumbleWindow)}')`; + return `(${timeField}, '${tumbleWindow} ${tumbleInterval}${pluralizeTime(tumbleWindow)}')`; }; /* @@ -154,10 +150,10 @@ const buildTumbleValue = (GroupByTumbleValue: GroupByTumbleType) => { * * CREATE MATERIALIZED VIEW datasource.database.index_name * AS SELECT - * count(`field`) as `counter`, - * count(*) as `counter1`, - * sum(`field2`), - * avg(`field3`) as `average` + * count(field) as counter, + * count(*) as counter1, + * sum(field2), + * avg(field3) as average * WITH ( * auto_refresh = true, * refresh_interval = '1 minute', diff --git a/test/mocks/accelerationMock.ts b/test/mocks/accelerationMock.ts index 47c96000..16ea9391 100644 --- a/test/mocks/accelerationMock.ts +++ b/test/mocks/accelerationMock.ts @@ -236,24 +236,11 @@ export const skippingIndexBuilderMock1: CreateAccelerationForm = { checkpointLocation: 's3://test/', }; -export const indexOptionsMock6: CreateAccelerationForm = { - ...createAccelerationEmptyDataMock, - primaryShardsCount: 1, - replicaShardsCount: 1, - refreshType: 'manual', - checkpointLocation: 's3://dsfsad/dasda', -}; - -export const indexOptionsMockResult6 = `WITH ( -index_settings = '{"number_of_shards":1,"number_of_replicas":1}', -auto_refresh = false -)`; - export const skippingIndexBuilderMockResult1 = `CREATE SKIPPING INDEX ON datasource.database.table ( - \`field1\` PARTITION, - \`field2\` VALUE_SET, - \`field3\` MIN_MAX + field1 PARTITION, + field2 VALUE_SET, + field3 MIN_MAX ) WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', auto_refresh = true, @@ -282,7 +269,7 @@ export const skippingIndexBuilderMock2: CreateAccelerationForm = { export const skippingIndexBuilderMockResult2 = `CREATE SKIPPING INDEX ON datasource.database.table ( - \`field1\` PARTITION + field1 PARTITION ) WITH ( index_settings = '{"number_of_shards":5,"number_of_replicas":3}', auto_refresh = true, @@ -308,9 +295,9 @@ export const coveringIndexBuilderMock1: CreateAccelerationForm = { export const coveringIndexBuilderMockResult1 = `CREATE INDEX index_name ON datasource.database.table ( - \`field1\`, - \`field2\`, - \`field3\` + field1, + field2, + field3 ) WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', auto_refresh = true, @@ -333,7 +320,7 @@ export const coveringIndexBuilderMock2: CreateAccelerationForm = { export const coveringIndexBuilderMockResult2 = `CREATE INDEX index_name ON datasource.database.table ( - \`field1\` + field1 ) WITH ( index_settings = '{"number_of_shards":5,"number_of_replicas":3}', auto_refresh = true, @@ -376,12 +363,12 @@ export const materializedViewBuilderMock1: CreateAccelerationForm = { export const materializedViewBuilderMockResult1 = `CREATE MATERIALIZED VIEW datasource.database.index_name AS SELECT - count(\`field\`) AS \`counter\`, - count(*) AS \`counter1\`, - sum(\`field2\`), - avg(\`field3\`) AS \`average\` + count(field) AS counter, + count(*) AS counter1, + sum(field2), + avg(field3) AS average FROM datasource.database.table -GROUP BY TUMBLE (\`timestamp\`, '1 minute') +GROUP BY TUMBLE (timestamp, '1 minute') WITH ( index_settings = '{"number_of_shards":9,"number_of_replicas":2}', auto_refresh = true, @@ -417,9 +404,9 @@ export const materializedViewBuilderMock2: CreateAccelerationForm = { export const materializedViewBuilderMockResult2 = `CREATE MATERIALIZED VIEW datasource.database.index_name AS SELECT - count(\`field\`) + count(field) FROM datasource.database.table -GROUP BY TUMBLE (\`timestamp\`, '2 hours') +GROUP BY TUMBLE (timestamp, '2 hours') WITH ( index_settings = '{"number_of_shards":5,"number_of_replicas":3}', auto_refresh = true,