mirror of https://github.com/apache/druid.git
Web console: Update dqt to a version that adds quotes by default (#13243)
* update dqt * auto quote by default
This commit is contained in:
parent
4775427e2c
commit
32020247d1
|
@ -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
|
||||
|
||||
---
|
||||
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
`);
|
||||
|
|
|
@ -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
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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':
|
||||
|
|
|
@ -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 '=':
|
||||
|
|
|
@ -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(', ');
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ exports[`IngestSuccessPane matches snapshot 1`] = `
|
|||
className="action"
|
||||
onClick={[Function]}
|
||||
>
|
||||
SELECT * FROM kttm_simple
|
||||
SELECT * FROM "kttm_simple"
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue