Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add backticks and remove ckpt for manual refresh in acceleration flyout #183

Merged
merged 2 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions public/components/acceleration/visual_editors/query_builder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};

Expand All @@ -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',
Expand All @@ -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');
};

/*
Expand All @@ -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',
Expand All @@ -127,12 +127,16 @@ ${buildCoveringIndexColumns(coveringIndexQueryData)}
return codeQuery;
};

const buildMaterializedViewColumnName = (columnName: string) => {
return columnName === '*' ? columnName : `\`${columnName}\``;
};

const buildMaterializedViewColumns = (columnsValues: MaterializedViewColumn[]) => {
return columnsValues
.map(
(column) =>
` ${column.functionName}(${column.functionParam})${
column.fieldAlias ? ` AS ${column.fieldAlias}` : ``
` ${column.functionName}(${buildMaterializedViewColumnName(column.functionParam)})${
column.fieldAlias ? ` AS \`${column.fieldAlias}\`` : ``
}`
)
.join(', \n');
Expand All @@ -141,7 +145,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)}')`;
};

/*
Expand All @@ -150,10 +154,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',
Expand Down
30 changes: 15 additions & 15 deletions test/mocks/accelerationMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ export const skippingIndexBuilderMock1: CreateAccelerationForm = {

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,
Expand Down Expand Up @@ -269,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,
Expand All @@ -295,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,
Expand All @@ -320,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,
Expand Down Expand Up @@ -363,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,
Expand Down Expand Up @@ -404,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,
Expand Down
Loading