From 32020247d12dd5776b83342848dd4a54cb339a9b Mon Sep 17 00:00:00 2001 From: Vadim Ogievetsky Date: Fri, 28 Oct 2022 01:06:45 -0700 Subject: [PATCH] Web console: Update dqt to a version that adds quotes by default (#13243) * update dqt * auto quote by default --- licenses.yaml | 2 +- web-console/package-lock.json | 14 ++++---- web-console/package.json | 2 +- .../ingest-query-pattern.spec.ts | 4 +-- .../workbench-query/workbench-query.spec.ts | 2 +- .../src/helpers/spec-conversion.spec.ts | 32 +++++++++---------- web-console/src/helpers/spec-conversion.ts | 12 +++---- .../src/react-table/react-table-utils.ts | 2 +- web-console/src/utils/druid-query.ts | 2 +- web-console/src/utils/sample-query.spec.tsx | 10 +++--- .../src/views/segments-view/segments-view.tsx | 2 +- .../ingest-success-pane.spec.tsx.snap | 2 +- 12 files changed, 42 insertions(+), 44 deletions(-) diff --git a/licenses.yaml b/licenses.yaml index 312d5999ebc..cc387083f35 100644 --- a/licenses.yaml +++ b/licenses.yaml @@ -5673,7 +5673,7 @@ license_category: binary module: web-console license_name: Apache License version 2.0 copyright: Imply Data -version: 0.15.3 +version: 0.16.1 --- diff --git a/web-console/package-lock.json b/web-console/package-lock.json index 5f1e35cef33..31d0a107aca 100644 --- a/web-console/package-lock.json +++ b/web-console/package-lock.json @@ -22,7 +22,7 @@ "d3-axis": "^2.1.0", "d3-scale": "^3.3.0", "d3-selection": "^2.0.0", - "druid-query-toolkit": "^0.15.3", + "druid-query-toolkit": "^0.16.1", "file-saver": "^2.0.2", "follow-redirects": "^1.14.7", "fontsource-open-sans": "^3.0.9", @@ -8967,9 +8967,9 @@ } }, "node_modules/druid-query-toolkit": { - "version": "0.15.3", - "resolved": "https://registry.npmjs.org/druid-query-toolkit/-/druid-query-toolkit-0.15.3.tgz", - "integrity": "sha512-AtKnmCDWSHh1+bHFs36drJAKQ60914ttF62x3wIxXbD1zoUEmwwsX4Ks2zD3SItantVS4fTj3cyjMl/c0fojpA==", + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/druid-query-toolkit/-/druid-query-toolkit-0.16.1.tgz", + "integrity": "sha512-HiovpGh1m2QTvexBX1AvQAz5ONc9sChazL0hsXl0qEvHcIQ69pksJZWXZOStBI2T9fJAXQpSUVB4DUSdE6UXmQ==", "dependencies": { "tslib": "^2.3.1" }, @@ -34591,9 +34591,9 @@ } }, "druid-query-toolkit": { - "version": "0.15.3", - "resolved": "https://registry.npmjs.org/druid-query-toolkit/-/druid-query-toolkit-0.15.3.tgz", - "integrity": "sha512-AtKnmCDWSHh1+bHFs36drJAKQ60914ttF62x3wIxXbD1zoUEmwwsX4Ks2zD3SItantVS4fTj3cyjMl/c0fojpA==", + "version": "0.16.1", + "resolved": "https://registry.npmjs.org/druid-query-toolkit/-/druid-query-toolkit-0.16.1.tgz", + "integrity": "sha512-HiovpGh1m2QTvexBX1AvQAz5ONc9sChazL0hsXl0qEvHcIQ69pksJZWXZOStBI2T9fJAXQpSUVB4DUSdE6UXmQ==", "requires": { "tslib": "^2.3.1" } diff --git a/web-console/package.json b/web-console/package.json index 6cde5763041..1d08bc4c4ee 100644 --- a/web-console/package.json +++ b/web-console/package.json @@ -79,7 +79,7 @@ "d3-axis": "^2.1.0", "d3-scale": "^3.3.0", "d3-selection": "^2.0.0", - "druid-query-toolkit": "^0.15.3", + "druid-query-toolkit": "^0.16.1", "file-saver": "^2.0.2", "follow-redirects": "^1.14.7", "fontsource-open-sans": "^3.0.9", diff --git a/web-console/src/druid-models/ingest-query-pattern/ingest-query-pattern.spec.ts b/web-console/src/druid-models/ingest-query-pattern/ingest-query-pattern.spec.ts index d8ec89f1725..f7827ea4cd1 100644 --- a/web-console/src/druid-models/ingest-query-pattern/ingest-query-pattern.spec.ts +++ b/web-console/src/druid-models/ingest-query-pattern/ingest-query-pattern.spec.ts @@ -24,7 +24,7 @@ describe('ingest-query-pattern', () => { it('works', () => { const query = SqlQuery.parse(sane` INSERT INTO "kttm-2019" - WITH ext AS (SELECT * + WITH "ext" AS (SELECT * FROM TABLE( EXTERN( '{"type":"http","uris":["https://example.com/data.json.gz"]}', @@ -38,7 +38,7 @@ describe('ingest-query-pattern', () => { agent_type, browser, browser_version - FROM ext + FROM "ext" PARTITIONED BY HOUR CLUSTERED BY 4 `); diff --git a/web-console/src/druid-models/workbench-query/workbench-query.spec.ts b/web-console/src/druid-models/workbench-query/workbench-query.spec.ts index 8f6f2581e1d..5d7e2615098 100644 --- a/web-console/src/druid-models/workbench-query/workbench-query.spec.ts +++ b/web-console/src/druid-models/workbench-query/workbench-query.spec.ts @@ -157,7 +157,7 @@ describe('WorkbenchQuery', () => { '[{"name":"timestamp","type":"string"}]' ) ) - ORDER BY FLOOR(__time TO HOUR), browser, session + ORDER BY FLOOR("__time" TO HOUR), browser, session `); }); }); diff --git a/web-console/src/helpers/spec-conversion.spec.ts b/web-console/src/helpers/spec-conversion.spec.ts index 43e7d31fac5..0239da18541 100644 --- a/web-console/src/helpers/spec-conversion.spec.ts +++ b/web-console/src/helpers/spec-conversion.spec.ts @@ -115,8 +115,8 @@ describe('spec conversion', () => { expect(converted.queryString).toEqual(sane` -- This SQL query was auto generated from an ingestion spec - REPLACE INTO wikipedia OVERWRITE ALL - WITH source AS (SELECT * FROM TABLE( + REPLACE INTO "wikipedia" OVERWRITE ALL + WITH "source" AS (SELECT * FROM TABLE( EXTERN( '{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}', '{"type":"json"}', @@ -148,7 +148,7 @@ describe('spec conversion', () => { "metroCode", "countryIsoCode", "regionName" - FROM source + FROM "source" WHERE NOT ("channel" = 'xxx') PARTITIONED BY HOUR CLUSTERED BY "isRobot" @@ -255,8 +255,8 @@ describe('spec conversion', () => { expect(converted.queryString).toEqual(sane` -- This SQL query was auto generated from an ingestion spec - REPLACE INTO wikipedia_rollup OVERWRITE ALL - WITH source AS (SELECT * FROM TABLE( + REPLACE INTO "wikipedia_rollup" OVERWRITE ALL + WITH "source" AS (SELECT * FROM TABLE( EXTERN( '{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}', '{"type":"json"}', @@ -288,7 +288,7 @@ describe('spec conversion', () => { SUM("deltaBucket") AS "sum_deltaBucket", SUM("deleted") AS "sum_deleted", APPROX_COUNT_DISTINCT_DS_THETA("page") AS "page_theta" - FROM source + FROM "source" GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 PARTITIONED BY HOUR `); @@ -417,8 +417,8 @@ describe('spec conversion', () => { expect(converted.queryString).toEqual(sane` -- This SQL query was auto generated from an ingestion spec - REPLACE INTO newSource OVERWRITE ALL - WITH source AS (SELECT * FROM TABLE( + REPLACE INTO "newSource" OVERWRITE ALL + WITH "source" AS (SELECT * FROM TABLE( EXTERN( '{"type":"s3","uris":["s3://path"]}', '{"columns":["col1","col2","col3","col4","metric1","metric2","metric3","metric4","metric5","metric6","metric7"],"type":"timeAndDims"}', @@ -426,7 +426,7 @@ describe('spec conversion', () => { ) )) SELECT - TIME_FLOOR(CASE WHEN CAST(event_ts AS BIGINT) > 0 THEN MILLIS_TO_TIMESTAMP(CAST(event_ts AS BIGINT)) ELSE TIME_PARSE(event_ts) END, 'PT1H') AS __time, + TIME_FLOOR(CASE WHEN CAST("event_ts" AS BIGINT) > 0 THEN MILLIS_TO_TIMESTAMP(CAST("event_ts" AS BIGINT)) ELSE TIME_PARSE("event_ts") END, 'PT1H') AS __time, "col1", "col2", "col3", @@ -438,7 +438,7 @@ describe('spec conversion', () => { APPROX_COUNT_DISTINCT_BUILTIN("field5") AS "metric5", SUM("field6") AS "metric6", SUM("field7") AS "metric7" - FROM source + FROM "source" WHERE "col2" = 'xxx' GROUP BY 1, 2, 3, 4, 5 PARTITIONED BY HOUR @@ -537,8 +537,8 @@ describe('spec conversion', () => { expect(converted.queryString).toEqual(sane` -- This SQL query was auto generated from an ingestion spec - REPLACE INTO wikipedia OVERWRITE ALL - WITH source AS (SELECT * FROM TABLE( + REPLACE INTO "wikipedia" OVERWRITE ALL + WITH "source" AS (SELECT * FROM TABLE( EXTERN( '{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}', '{"type":"json"}', @@ -571,7 +571,7 @@ describe('spec conversion', () => { "metroCode", "countryIsoCode", "regionName" - FROM source + FROM "source" PARTITIONED BY HOUR CLUSTERED BY "isRobot" `); @@ -667,8 +667,8 @@ describe('spec conversion', () => { expect(converted.queryString).toEqual(sane` -- This SQL query was auto generated from an ingestion spec - REPLACE INTO wikipedia OVERWRITE ALL - WITH source AS (SELECT * FROM TABLE( + REPLACE INTO "wikipedia" OVERWRITE ALL + WITH "source" AS (SELECT * FROM TABLE( EXTERN( '{"type":"http","uris":["https://druid.apache.org/data/wikipedia.json.gz"]}', '{"type":"json"}', @@ -701,7 +701,7 @@ describe('spec conversion', () => { "metroCode", "countryIsoCode", "regionName" - FROM source + FROM "source" WHERE REWRITE_[{"type":"strange"}]_TO_SQL --:ISSUE: The spec contained a filter that could not be automatically converted, please convert it manually PARTITIONED BY HOUR CLUSTERED BY "isRobot" diff --git a/web-console/src/helpers/spec-conversion.ts b/web-console/src/helpers/spec-conversion.ts index 9eedcce9f79..76bdc16a924 100644 --- a/web-console/src/helpers/spec-conversion.ts +++ b/web-console/src/helpers/spec-conversion.ts @@ -38,10 +38,10 @@ export function getSpecDatasourceName(spec: IngestionSpec): string { function convertFilter(filter: any): SqlExpression { switch (filter.type) { case 'selector': - return SqlRef.columnWithQuotes(filter.dimension).equal(filter.value); + return SqlRef.column(filter.dimension).equal(filter.value); case 'in': - return SqlRef.columnWithQuotes(filter.dimension).in(filter.values); + return SqlRef.column(filter.dimension).in(filter.values); case 'not': return convertFilter(filter.field).not(); @@ -264,7 +264,7 @@ export function convertSpecToSql(spec: any): QueryWithContext { const relevantTransform = transforms.find(t => t.name === dimensionName); return ` ${ relevantTransform ? `REWRITE_[${relevantTransform.expression}]_TO_SQL AS ` : '' - }${SqlRef.columnWithQuotes(dimensionName)},${ + }${SqlRef.column(dimensionName)},${ relevantTransform ? ` --:ISSUE: Transform for dimension could not be converted` : '' }`; }), @@ -316,9 +316,7 @@ export function convertSpecToSql(spec: any): QueryWithContext { partitionsSpec.partitionDimensions || (partitionsSpec.partitionDimension ? [partitionsSpec.partitionDimension] : undefined); if (Array.isArray(partitionDimensions)) { - lines.push( - `CLUSTERED BY ${partitionDimensions.map(d => SqlRef.columnWithQuotes(d)).join(', ')}`, - ); + lines.push(`CLUSTERED BY ${partitionDimensions.map(d => SqlRef.column(d)).join(', ')}`); } return { @@ -399,7 +397,7 @@ function metricSpecToSqlExpression(metricSpec: MetricSpec): string | undefined { } if (!metricSpec.fieldName) return; - const ref = SqlRef.columnWithQuotes(metricSpec.fieldName); + const ref = SqlRef.column(metricSpec.fieldName); switch (metricSpec.type) { case 'longSum': diff --git a/web-console/src/react-table/react-table-utils.ts b/web-console/src/react-table/react-table-utils.ts index 7cdaddbad3d..2563ceffd34 100644 --- a/web-console/src/react-table/react-table-utils.ts +++ b/web-console/src/react-table/react-table-utils.ts @@ -142,7 +142,7 @@ export function sqlQueryCustomTableFilter(filter: Filter): SqlExpression | undef const modeAndNeedle = parseFilterModeAndNeedle(filter); if (!modeAndNeedle) return; const { mode, needle } = modeAndNeedle; - const column = SqlRef.columnWithQuotes(filter.id); + const column = SqlRef.column(filter.id); const needleLiteral = SqlLiteral.create(needle); switch (mode) { case '=': diff --git a/web-console/src/utils/druid-query.ts b/web-console/src/utils/druid-query.ts index e63b7ff89ce..2253d4d6b3d 100644 --- a/web-console/src/utils/druid-query.ts +++ b/web-console/src/utils/druid-query.ts @@ -309,6 +309,6 @@ export interface QueryExplanation { export function formatSignature(queryExplanation: QueryExplanation): string { return queryExplanation.signature - .map(({ name, type }) => `${SqlRef.column(name)}::${type}`) + .map(({ name, type }) => `${SqlRef.columnWithoutQuotes(name)}::${type}`) .join(', '); } diff --git a/web-console/src/utils/sample-query.spec.tsx b/web-console/src/utils/sample-query.spec.tsx index 23ab099f156..ef42a4b054c 100644 --- a/web-console/src/utils/sample-query.spec.tsx +++ b/web-console/src/utils/sample-query.spec.tsx @@ -48,13 +48,13 @@ describe('sample-query', () => { expect(sampleDataToQuery(result).toString()).toEqual(sane` SELECT - CAST(c0 AS TIMESTAMP) AS "__time", - CAST(c1 AS VARCHAR) AS "host", - CAST(c2 AS VARCHAR) AS "service", - PARSE_JSON(c3) AS "msg" + CAST("c0" AS TIMESTAMP) AS "__time", + CAST("c1" AS VARCHAR) AS "host", + CAST("c2" AS VARCHAR) AS "service", + PARSE_JSON("c3") AS "msg" FROM (VALUES ('2022-02-01T00:00:00.000Z', 'brokerA.internal', 'broker', '"{\\"type\\":\\"sys\\",\\"swap/free\\":1223334,\\"swap/max\\":3223334}"'), - ('2022-02-01T00:00:00.000Z', 'brokerA.internal', 'broker', '"{\\"type\\":\\"query\\",\\"time\\":1223,\\"bytes\\":2434234}"')) AS t ("c0", "c1", "c2", "c3") + ('2022-02-01T00:00:00.000Z', 'brokerA.internal', 'broker', '"{\\"type\\":\\"query\\",\\"time\\":1223,\\"bytes\\":2434234}"')) AS "t" ("c0", "c1", "c2", "c3") `); }); }); diff --git a/web-console/src/views/segments-view/segments-view.tsx b/web-console/src/views/segments-view/segments-view.tsx index 85d02796226..4f9ee21a298 100644 --- a/web-console/src/views/segments-view/segments-view.tsx +++ b/web-console/src/views/segments-view/segments-view.tsx @@ -294,7 +294,7 @@ END AS "time_span"`, } } else if (f.id.startsWith('is_')) { if (f.value === 'all') return; - return SqlRef.columnWithQuotes(f.id).equal(f.value === 'true' ? 1 : 0); + return SqlRef.column(f.id).equal(f.value === 'true' ? 1 : 0); } else { return sqlQueryCustomTableFilter(f); } diff --git a/web-console/src/views/workbench-view/ingest-success-pane/__snapshots__/ingest-success-pane.spec.tsx.snap b/web-console/src/views/workbench-view/ingest-success-pane/__snapshots__/ingest-success-pane.spec.tsx.snap index 9f37518e64b..72f467c76b4 100644 --- a/web-console/src/views/workbench-view/ingest-success-pane/__snapshots__/ingest-success-pane.spec.tsx.snap +++ b/web-console/src/views/workbench-view/ingest-success-pane/__snapshots__/ingest-success-pane.spec.tsx.snap @@ -23,7 +23,7 @@ exports[`IngestSuccessPane matches snapshot 1`] = ` className="action" onClick={[Function]} > - SELECT * FROM kttm_simple + SELECT * FROM "kttm_simple"