Skip to content

Commit 109e8c6

Browse files
committed
More query schema improvements and some layout tweaks
1 parent 19febd5 commit 109e8c6

File tree

3 files changed

+58
-29
lines changed

3 files changed

+58
-29
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ export default function Page() {
251251
<ResizablePanel id="query-main" className="max-h-full">
252252
<div className="grid max-h-full grid-rows-[auto_1fr] overflow-hidden">
253253
{/* Query editor */}
254-
<div className="flex flex-col gap-2 pb-2">
254+
<div className="flex flex-col gap-2 bg-charcoal-900 pb-2">
255255
<TSQLEditor
256256
defaultValue={query}
257257
onChange={setQuery}
@@ -315,8 +315,8 @@ export default function Page() {
315315
</Form>
316316
</div>
317317
{/* Results */}
318-
<div className="grid max-h-full grid-rows-[2rem_1fr] overflow-hidden border-t border-grid-dimmed">
319-
<div className="flex items-center justify-between border-b border-grid-dimmed bg-charcoal-900 pl-3 pr-1">
318+
<div className="grid max-h-full grid-rows-[2rem_1fr] overflow-hidden border-t border-grid-dimmed bg-charcoal-800">
319+
<div className="flex items-center justify-between border-b border-grid-dimmed pl-3 pr-1">
320320
<div className="flex items-center gap-2">
321321
<Header3>
322322
{results?.rows?.length ? `${results.rows.length} Results` : "Results"}
@@ -506,7 +506,7 @@ const exampleQueries: Array<{
506506
count() AS failed_count
507507
FROM runs
508508
WHERE status = 'Failed'
509-
AND created_at > now() - INTERVAL 7 DAY
509+
AND triggered_at > now() - INTERVAL 7 DAY
510510
GROUP BY task_identifier
511511
ORDER BY failed_count DESC
512512
LIMIT 20`,
@@ -519,7 +519,7 @@ LIMIT 20`,
519519
task_identifier,
520520
quantile(0.5)(execution_duration) AS p50_duration_ms
521521
FROM runs
522-
WHERE created_at > now() - INTERVAL 7 DAY
522+
WHERE triggered_at > now() - INTERVAL 7 DAY
523523
AND execution_duration IS NOT NULL
524524
GROUP BY task_identifier
525525
ORDER BY p50_duration_ms DESC
@@ -538,7 +538,7 @@ LIMIT 20`,
538538
machine,
539539
created_at
540540
FROM runs
541-
WHERE created_at > now() - INTERVAL 7 DAY
541+
WHERE triggered_at > now() - INTERVAL 7 DAY
542542
ORDER BY total_cost DESC
543543
LIMIT 100`,
544544
scope: "environment",

apps/webapp/app/v3/querySchemas.ts

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { column, type TableSchema } from "@internal/tsql";
22
import { runFriendlyStatus, runStatusTitleFromStatus } from "~/components/runs/v3/TaskRunStatus";
3+
import { logger } from "~/services/logger.server";
34

45
/**
56
* Environment type values
@@ -122,6 +123,7 @@ export const runsSchema: TableSchema = {
122123
customRenderType: "runId",
123124
expression: "if(root_run_id = '', NULL, 'run_' || root_run_id)",
124125
}),
126+
whereTransform: (value: string) => value.replace(/^run_/, ""),
125127
},
126128
parent_run_id: {
127129
name: "parent_run_id",
@@ -131,6 +133,7 @@ export const runsSchema: TableSchema = {
131133
customRenderType: "runId",
132134
expression: "if(parent_run_id = '', NULL, 'run_' || parent_run_id)",
133135
}),
136+
whereTransform: (value: string) => value.replace(/^run_/, ""),
134137
},
135138
depth: {
136139
name: "depth",
@@ -226,7 +229,7 @@ export const runsSchema: TableSchema = {
226229
name: "ttl",
227230
clickhouseName: "expiration_ttl",
228231
...column("String", {
229-
description: "TTL string for expiration. By default dev runs have a TTL of 10m.",
232+
description: "The TTL string for expiration – by default dev runs have a TTL of '10m'.",
230233
example: "10m",
231234
}),
232235
},
@@ -268,7 +271,7 @@ export const runsSchema: TableSchema = {
268271
name: "usage_duration",
269272
clickhouseName: "usage_duration_ms",
270273
...column("UInt32", {
271-
description: "Usage duration in milliseconds",
274+
description: "Compute usage duration in milliseconds.",
272275
customRenderType: "duration",
273276
example: "3500",
274277
}),
@@ -285,7 +288,7 @@ export const runsSchema: TableSchema = {
285288
invocation_cost: {
286289
name: "invocation_cost",
287290
...column("Float64", {
288-
description: "Invocation cost in dollars",
291+
description: "Invocation cost in dollars – the cost to start a run.",
289292
customRenderType: "costInDollars",
290293
example: "0.000025",
291294
}),
@@ -304,13 +307,17 @@ export const runsSchema: TableSchema = {
304307
// Output & error (JSON columns)
305308
output: {
306309
name: "output",
307-
...column("JSON", { description: "Run output data", example: '{"result": "success"}' }),
310+
...column("JSON", {
311+
description: "The data you returned from the task.",
312+
example: '{"result": "success"}',
313+
}),
308314
expression: "if(output = '{}', NULL, output)",
309315
},
310316
error: {
311317
name: "error",
312318
...column("JSON", {
313-
description: "Error information",
319+
description:
320+
"If a run completely failed (after all attempts) then this error will be populated.",
314321
example: '{"message": "Task failed"}',
315322
}),
316323
expression: "if(error = '{}', NULL, error)",
@@ -320,40 +327,65 @@ export const runsSchema: TableSchema = {
320327
tags: {
321328
name: "tags",
322329
...column("Array(String)", {
323-
description: "Run tags",
330+
description: "Tags you have added to the run.",
324331
customRenderType: "tags",
325332
example: '["user:123", "priority:high"]',
326333
}),
327334
},
328335
task_version: {
329336
name: "task_version",
330-
...column("String", { description: "Task version", example: "20240115.1" }),
337+
...column("String", {
338+
description: "The version of your code in reverse date format.",
339+
example: "20240115.1",
340+
}),
331341
},
332342
sdk_version: {
333343
name: "sdk_version",
334-
...column("String", { description: "SDK version", example: "3.3.0" }),
344+
...column("String", {
345+
description: "The SDK package version for this run.",
346+
example: "3.3.0",
347+
}),
335348
},
336349
cli_version: {
337350
name: "cli_version",
338-
...column("String", { description: "CLI version", example: "3.3.0" }),
351+
...column("String", {
352+
description: "The CLI package version for this run.",
353+
example: "3.3.0",
354+
}),
339355
},
340356
machine: {
341357
name: "machine",
342358
clickhouseName: "machine_preset",
343359
...column("LowCardinality(String)", {
344-
description: "Machine preset",
360+
description: "The machine that the run executed on.",
345361
allowedValues: [...MACHINE_PRESETS],
346362
customRenderType: "machine",
347363
example: "small-1x",
348364
}),
349365
},
350-
351-
// Flags
352366
is_test: {
353367
name: "is_test",
354368
...column("UInt8", { description: "Whether this is a test run (0 or 1)", example: "0" }),
355369
expression: "if(is_test > 0, true, false)",
356370
},
371+
concurrency_key: {
372+
name: "concurrency_key",
373+
...column("String", {
374+
description: "The concurrency key you passed in when triggering the run.",
375+
example: "user:1234567",
376+
}),
377+
},
378+
bulk_action_group_ids: {
379+
name: "bulk_action_group_ids",
380+
...column("Array(String)", {
381+
description: "Any bulk actions that operated on this run.",
382+
example: '["bulk_12345678", "bulk_34567890"]',
383+
whereTransform: (value: string) => {
384+
logger.log(`WHERE TRANSFORM: ${value}`);
385+
return value.replace(/^bulk_/, "");
386+
},
387+
}),
388+
},
357389
},
358390
};
359391

@@ -365,15 +397,7 @@ export const querySchemas: TableSchema[] = [runsSchema];
365397
/**
366398
* Default query for the query editor
367399
*/
368-
export const defaultQuery = `SELECT
369-
run_id,
370-
task_identifier,
371-
status,
372-
created_at,
373-
usage_duration,
374-
compute_cost,
375-
invocation_cost,
376-
machine,
400+
export const defaultQuery = `SELECT *
377401
FROM runs
378-
ORDER BY created_at DESC
379-
LIMIT 10`;
402+
ORDER BY triggered_at DESC
403+
LIMIT 100`;

internal-packages/tsql/src/query/printer.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ export class ClickHousePrinter {
964964
return "Float64";
965965
}
966966

967+
// Quantile functions return Float64
968+
if (name === "quantile" || name === "quantileif" || name.startsWith("quantile")) {
969+
return "Float64";
970+
}
971+
967972
// Min/Max preserve the input type - try to infer from first arg
968973
if (name === "min" || name === "max" || name === "minif" || name === "maxif") {
969974
if (call.args.length > 0) {

0 commit comments

Comments
 (0)