@hypequery/datasets 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +18 -0
  2. package/dist/client-contract/build-from-datasets.d.ts +39 -0
  3. package/dist/client-contract/build-from-datasets.d.ts.map +1 -0
  4. package/dist/client-contract/build-from-datasets.js +82 -0
  5. package/dist/client-contract/build-from-deployment.d.ts +13 -0
  6. package/dist/client-contract/build-from-deployment.d.ts.map +1 -1
  7. package/dist/client-contract/build-from-deployment.js +3 -2
  8. package/dist/client-contract/dataset-annotations.d.ts +14 -0
  9. package/dist/client-contract/dataset-annotations.d.ts.map +1 -0
  10. package/dist/client-contract/dataset-annotations.js +27 -0
  11. package/dist/client-contract/dataset-fields.d.ts +24 -0
  12. package/dist/client-contract/dataset-fields.d.ts.map +1 -0
  13. package/dist/client-contract/dataset-fields.js +109 -0
  14. package/dist/client-contract/deployment-fields.d.ts +4 -3
  15. package/dist/client-contract/deployment-fields.d.ts.map +1 -1
  16. package/dist/client-contract/deployment-fields.js +15 -12
  17. package/dist/client-contract/deployment-profile.d.ts +9 -0
  18. package/dist/client-contract/deployment-profile.d.ts.map +1 -1
  19. package/dist/client-contract/deployment-profile.js +10 -6
  20. package/dist/execution-capabilities.json +4 -4
  21. package/dist/executor.d.ts +33 -1
  22. package/dist/executor.d.ts.map +1 -1
  23. package/dist/executor.js +59 -0
  24. package/dist/index.d.ts +4 -2
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +1 -0
  27. package/dist/internal.d.ts +1 -0
  28. package/dist/internal.d.ts.map +1 -1
  29. package/dist/internal.js +1 -0
  30. package/dist/metric-query-engine.d.ts +9 -0
  31. package/dist/metric-query-engine.d.ts.map +1 -1
  32. package/dist/metric-query-engine.js +25 -15
  33. package/dist/protocol-adapter.d.ts.map +1 -1
  34. package/dist/protocol-adapter.js +6 -0
  35. package/dist/query-builder-protocol.d.ts +32 -0
  36. package/dist/query-builder-protocol.d.ts.map +1 -1
  37. package/dist/semantic-query-schema.d.ts.map +1 -1
  38. package/dist/semantic-query-schema.js +19 -11
  39. package/dist/types.d.ts +58 -7
  40. package/dist/types.d.ts.map +1 -1
  41. package/dist/utils/compile-dataset-query.d.ts +9 -3
  42. package/dist/utils/compile-dataset-query.d.ts.map +1 -1
  43. package/dist/utils/compile-dataset-query.js +11 -9
  44. package/dist/utils/dataset-filter-types.d.ts +35 -10
  45. package/dist/utils/dataset-filter-types.d.ts.map +1 -1
  46. package/dist/utils/dataset-query-validation.d.ts.map +1 -1
  47. package/dist/utils/dataset-query-validation.js +5 -3
  48. package/dist/utils/effective-filters.d.ts +27 -0
  49. package/dist/utils/effective-filters.d.ts.map +1 -0
  50. package/dist/utils/effective-filters.js +36 -0
  51. package/dist/utils/enforced-constraints.d.ts.map +1 -1
  52. package/dist/utils/enforced-constraints.js +5 -3
  53. package/dist/utils/metric-query-validation.d.ts.map +1 -1
  54. package/dist/utils/metric-query-validation.js +5 -3
  55. package/dist/utils/portable-semantic-query.d.ts.map +1 -1
  56. package/dist/utils/portable-semantic-query.js +11 -0
  57. package/dist/utils/relationship-measure-sql.d.ts.map +1 -1
  58. package/dist/utils/relationship-measure-sql.js +4 -2
  59. package/dist/utils/relationship-validation.d.ts.map +1 -1
  60. package/dist/utils/relationship-validation.js +5 -4
  61. package/dist/utils/semantic-stream.d.ts +6 -0
  62. package/dist/utils/semantic-stream.d.ts.map +1 -0
  63. package/dist/utils/semantic-stream.js +17 -0
  64. package/dist/utils/statement-runner.d.ts +31 -0
  65. package/dist/utils/statement-runner.d.ts.map +1 -0
  66. package/dist/utils/statement-runner.js +43 -0
  67. package/dist/utils/stream-ceiling.d.ts +10 -0
  68. package/dist/utils/stream-ceiling.d.ts.map +1 -0
  69. package/dist/utils/stream-ceiling.js +21 -0
  70. package/dist/utils/time-measure-axis-sql.d.ts.map +1 -1
  71. package/dist/utils/time-measure-axis-sql.js +4 -1
  72. package/package.json +6 -6
@@ -33,5 +33,16 @@ export function semanticQuery(operation, maxRows) {
33
33
  limit: operation.limit ?? maxRows,
34
34
  ...(operation.offset === undefined ? {} : { offset: operation.offset }),
35
35
  ...(operation.by === undefined ? {} : { by: operation.by }),
36
+ // RFC 0025: the dataset client applies both on the queryBuilder path,
37
+ // and validates `having` against the selection again.
38
+ ...(operation.kind === 'dataset' && operation.having !== undefined
39
+ ? {
40
+ having: operation.having.map(condition => ({
41
+ ...condition,
42
+ measure: String(condition.measure),
43
+ })),
44
+ }
45
+ : {}),
46
+ ...(operation.timezone === undefined ? {} : { timezone: operation.timezone }),
36
47
  };
37
48
  }
@@ -1 +1 @@
1
- {"version":3,"file":"relationship-measure-sql.d.ts","sourceRoot":"","sources":["../../src/utils/relationship-measure-sql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AAEvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAIjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAExE;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,sBAAsB;;;EAoBlJ;AAeD,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,sBAAsB;;;;EAexJ"}
1
+ {"version":3,"file":"relationship-measure-sql.d.ts","sourceRoot":"","sources":["../../src/utils/relationship-measure-sql.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AAEvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AAIjF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAExE;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,kBAAkB,EAAE,EAAE,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,OAAO,EAAE,sBAAsB;;;EAsBlJ;AAeD,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,EAAE,OAAO,EAAE,sBAAsB;;;;EAexJ"}
@@ -28,15 +28,17 @@ export function relationshipJoinSource(target, to, names, dialect) {
28
28
  columns.add(target.dimensions[field]?.column ?? field);
29
29
  }
30
30
  }
31
+ const current = currentRowPredicate(target);
31
32
  let marker = '_hq_match';
32
- while (columns.has(marker))
33
+ // The WHERE below reads the current-row column unqualified, so the marker
34
+ // alias must not take its name either.
35
+ while (columns.has(marker) || marker === current?.column)
33
36
  marker += '_';
34
37
  const quote = dialect.quoteIdentifier;
35
38
  const source = relationshipTargetTable(target, dialect);
36
39
  // Sorted so the SQL is byte-identical however the target's dimensions are
37
40
  // ordered (authored vs. rehydrated catalogs declare them differently).
38
41
  const projection = [...columns].sort().map(quote);
39
- const current = currentRowPredicate(target);
40
42
  const where = current ? ` WHERE ${quote(current.column)} = ${current.value}` : '';
41
43
  return { source: `(SELECT ${[...projection, `${dialect.toNullable('1')} AS ${quote(marker)}`].join(', ')} FROM ${source}${where})`, marker };
42
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"relationship-validation.d.ts","sourceRoot":"","sources":["../../src/utils/relationship-validation.ts"],"names":[],"mappings":"AAEA;;;GAGG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AAYrB,KAAK,iBAAiB,GAAG,IAAI,CAC3B,YAAY,GAAG,WAAW,EAC1B,YAAY,GAAG,SAAS,GAAG,SAAS,CACrC,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,kBAAkB,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,GAAG,IAAI,CA4Bf"}
1
+ {"version":3,"file":"relationship-validation.d.ts","sourceRoot":"","sources":["../../src/utils/relationship-validation.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACZ,MAAM,aAAa,CAAC;AAYrB,KAAK,iBAAiB,GAAG,IAAI,CAC3B,YAAY,GAAG,WAAW,EAC1B,YAAY,GAAG,SAAS,GAAG,SAAS,CACrC,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;AAEnC;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,EAAE,EAAE,kBAAkB,EACtB,KAAK,EAAE,iBAAiB,EACxB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,GAAG,SAAS,CAqBpB;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,EAAE,EAAE,kBAAkB,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,GAAG,IAAI,CA4Bf"}
@@ -1,5 +1,6 @@
1
1
  import { resolveRelationshipReference } from './relationship-measures.js';
2
2
  import { filterAllowsOperator } from './filter-operator-policy.js';
3
+ import { effectiveFilters } from './effective-filters.js';
3
4
  import { validateFilterValue } from '../validation.js';
4
5
  import { getRuntimeTenantPredicate, hasTenantRuntime, } from './tenant-runtime.js';
5
6
  import { runtimeConstraints } from './row-scope.js';
@@ -48,10 +49,10 @@ export function validateQualifiedFilter(ds, filter, context) {
48
49
  if (getRuntimeTenantPredicate(context) && target.tenantKey && targetColumn === target.tenantKey) {
49
50
  return `Cannot filter on tenant field "${filter.field}" when runtime tenancy enforcement is active.`;
50
51
  }
51
- // A relationship does not turn every target dimension into an exposed
52
- // filter. Apply the target's explicit or generated filter allowlist and
53
- // operator policy. An explicit filter can override filterable: false.
54
- const definition = target.filters[targetDimensionName];
52
+ // A relationship exposes the target's filters named after a dimension:
53
+ // its filterable dimensions, and declared filters, which can override
54
+ // filterable: false. A filter alias is not reachable through the hop.
55
+ const definition = effectiveFilters(target)[targetDimensionName];
55
56
  if (!definition
56
57
  || definition.field !== targetDimensionName) {
57
58
  return `Filter "${filter.field}" is not exposed by target dataset "${target.name}".`;
@@ -0,0 +1,6 @@
1
+ import type { ExecutionContext, SemanticStreamMeta } from '../types.js';
2
+ import type { ResultLimitMeta } from './result-limits.js';
3
+ /** Applies the row wire contract (measures as strings) to each streamed batch. */
4
+ export declare function serializeMeasureBatches<T>(batches: ReadableStream<T[]>, measureNames: readonly string[]): ReadableStream<T[]>;
5
+ export declare function semanticStreamMeta(sql: string, context: ExecutionContext | undefined, resultLimit: ResultLimitMeta | undefined): SemanticStreamMeta;
6
+ //# sourceMappingURL=semantic-stream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"semantic-stream.d.ts","sourceRoot":"","sources":["../../src/utils/semantic-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,kFAAkF;AAClF,wBAAgB,uBAAuB,CAAC,CAAC,EACvC,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAC5B,YAAY,EAAE,SAAS,MAAM,EAAE,GAC9B,cAAc,CAAC,CAAC,EAAE,CAAC,CAMrB;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,gBAAgB,GAAG,SAAS,EACrC,WAAW,EAAE,eAAe,GAAG,SAAS,GACvC,kBAAkB,CAMpB"}
@@ -0,0 +1,17 @@
1
+ import { serializeSemanticMeasureValues } from './semantic-result-serialization.js';
2
+ import { getRuntimeTenantId } from './tenant-runtime.js';
3
+ /** Applies the row wire contract (measures as strings) to each streamed batch. */
4
+ export function serializeMeasureBatches(batches, measureNames) {
5
+ return batches.pipeThrough(new TransformStream({
6
+ transform(batch, controller) {
7
+ controller.enqueue(serializeSemanticMeasureValues(batch, measureNames));
8
+ },
9
+ }));
10
+ }
11
+ export function semanticStreamMeta(sql, context, resultLimit) {
12
+ return {
13
+ sql,
14
+ tenant: getRuntimeTenantId(context),
15
+ ...(resultLimit ? { resultLimit } : {}),
16
+ };
17
+ }
@@ -0,0 +1,31 @@
1
+ import type { QueryBuilderFactoryLike, QueryBuilderLike } from '../query-builder-protocol.js';
2
+ type Rows = Record<string, unknown>[];
3
+ interface RawStatement {
4
+ readonly sql: string;
5
+ readonly parameters: readonly unknown[];
6
+ }
7
+ /**
8
+ * What a compiled semantic query runs as: the builder itself, which keeps the
9
+ * settings it carries, or a raw statement whose SQL already pins its own.
10
+ */
11
+ export type StatementTarget = {
12
+ kind: 'builder';
13
+ builder: QueryBuilderLike;
14
+ } | {
15
+ kind: 'raw';
16
+ statement: RawStatement;
17
+ };
18
+ /** One compiled query, runnable as a whole result or as a stream. */
19
+ export interface StatementRunner {
20
+ execute(): Promise<Rows>;
21
+ stream(): Promise<ReadableStream<Rows>>;
22
+ streamArrow(): Promise<ReadableStream<Uint8Array>>;
23
+ }
24
+ export interface StatementRunnerOptions {
25
+ abortSignal?: AbortSignal;
26
+ /** Raw statements that must succeed, in order, before the query runs. */
27
+ preflight?: readonly RawStatement[];
28
+ }
29
+ export declare function statementRunner(factory: QueryBuilderFactoryLike, target: StatementTarget, options?: StatementRunnerOptions): StatementRunner;
30
+ export {};
31
+ //# sourceMappingURL=statement-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statement-runner.d.ts","sourceRoot":"","sources":["../../src/utils/statement-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAE9F,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;AAEtC,UAAU,YAAY;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,CAAC;CACzC;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,SAAS,EAAE,YAAY,CAAA;CAAE,CAAC;AAE7C,qEAAqE;AACrE,MAAM,WAAW,eAAe;IAC9B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,WAAW,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;CACpD;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,yEAAyE;IACzE,SAAS,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CACrC;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,eAAe,EACvB,OAAO,GAAE,sBAA2B,GACnC,eAAe,CAqCjB"}
@@ -0,0 +1,43 @@
1
+ export function statementRunner(factory, target, options = {}) {
2
+ const { abortSignal, preflight = [] } = options;
3
+ const run = async (open) => {
4
+ for (const statement of preflight) {
5
+ await factory.rawQuery(statement.sql, [...statement.parameters], { abortSignal });
6
+ }
7
+ return open();
8
+ };
9
+ if (target.kind === 'builder') {
10
+ const { builder } = target;
11
+ return {
12
+ execute: () => run(() => builder.execute({ abortSignal })),
13
+ stream: () => run(() => {
14
+ if (!builder.stream)
15
+ throw unsupported('stream()', 'query builder');
16
+ return builder.stream({ abortSignal });
17
+ }),
18
+ streamArrow: () => run(() => {
19
+ if (!builder.streamArrow)
20
+ throw unsupported('streamArrow()', 'query builder');
21
+ return builder.streamArrow({ abortSignal });
22
+ }),
23
+ };
24
+ }
25
+ const { sql } = target.statement;
26
+ const parameters = () => [...target.statement.parameters];
27
+ return {
28
+ execute: () => run(() => factory.rawQuery(sql, parameters(), { abortSignal })),
29
+ stream: () => run(() => {
30
+ if (!factory.rawStream)
31
+ throw unsupported('rawStream()', 'query builder factory');
32
+ return factory.rawStream(sql, parameters(), { abortSignal });
33
+ }),
34
+ streamArrow: () => run(() => {
35
+ if (!factory.rawArrowStream)
36
+ throw unsupported('rawArrowStream()', 'query builder factory');
37
+ return factory.rawArrowStream(sql, parameters(), { abortSignal });
38
+ }),
39
+ };
40
+ }
41
+ function unsupported(method, owner) {
42
+ return new Error(`Streaming this query needs a ${owner} with ${method}; @hypequery/clickhouse provides it from 2.15.0.`);
43
+ }
@@ -0,0 +1,10 @@
1
+ import type { AnyDatasetInstance, GrainedMetricRef, MetricRef } from '../types.js';
2
+ /**
3
+ * *dataset* as a stream sees it: `limits.maxStreamRows`, when set, is its
4
+ * result ceiling. Every validator and planner reads the ceiling from
5
+ * `limits.maxResultSize`, so a view keeps one code path for pages and streams.
6
+ */
7
+ export declare function datasetForStream<TDataset extends AnyDatasetInstance>(dataset: TDataset): TDataset;
8
+ /** *metric* over its dataset's stream view; see {@link datasetForStream}. */
9
+ export declare function metricForStream<TMetric extends MetricRef | GrainedMetricRef>(metric: TMetric): TMetric;
10
+ //# sourceMappingURL=stream-ceiling.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream-ceiling.d.ts","sourceRoot":"","sources":["../../src/utils/stream-ceiling.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGnF;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,SAAS,kBAAkB,EAAE,OAAO,EAAE,QAAQ,GAAG,QAAQ,CAIjG;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,GAAG,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAMtG"}
@@ -0,0 +1,21 @@
1
+ import { getMetricRef } from './metric-handle.js';
2
+ /**
3
+ * *dataset* as a stream sees it: `limits.maxStreamRows`, when set, is its
4
+ * result ceiling. Every validator and planner reads the ceiling from
5
+ * `limits.maxResultSize`, so a view keeps one code path for pages and streams.
6
+ */
7
+ export function datasetForStream(dataset) {
8
+ const ceiling = dataset.limits?.maxStreamRows;
9
+ if (ceiling === undefined)
10
+ return dataset;
11
+ return { ...dataset, limits: { ...dataset.limits, maxResultSize: ceiling } };
12
+ }
13
+ /** *metric* over its dataset's stream view; see {@link datasetForStream}. */
14
+ export function metricForStream(metric) {
15
+ const ref = getMetricRef(metric);
16
+ const dataset = datasetForStream(ref.dataset);
17
+ if (dataset === ref.dataset)
18
+ return metric;
19
+ const viewed = { ...ref, dataset };
20
+ return (metric.__type === 'grained_metric_ref' ? { ...metric, metric: viewed } : viewed);
21
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"time-measure-axis-sql.d.ts","sourceRoot":"","sources":["../../src/utils/time-measure-axis-sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAqB,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,6DAA6D;AAC7D,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,eAAe,EACrB,MAAM,GAAE,SAAS,sBAAsB,EAAO,GAC7C,kBAAkB,CA2CpB"}
1
+ {"version":3,"file":"time-measure-axis-sql.d.ts","sourceRoot":"","sources":["../../src/utils/time-measure-axis-sql.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAqB,KAAK,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,6DAA6D;AAC7D,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,mBAAmB,EAC9B,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,eAAe,EACrB,MAAM,GAAE,SAAS,sBAAsB,EAAO,GAC7C,kBAAkB,CA8CpB"}
@@ -16,7 +16,10 @@ export function buildTimeMeasureAxisSql(statement, source, axis, shifts = []) {
16
16
  ? '0'
17
17
  : dialect.guard(`${count} > ${axis.resultLimit}`, `Window series exceeds the effective result limit of ${axis.resultLimit} buckets.`);
18
18
  const calendarGuard = calendarBucketGuardSql(dialect, '_hq_first', `${count} + ${limitGuard} + ${rangeGuard}`, axis.grain);
19
- const physicalTime = dialect.rowElement(`(SELECT ${source.rowAlias} FROM _hq_raw LIMIT 0)`, 1);
19
+ // A zero-row scalar reads the column type without scanning the source. It
20
+ // selects the time element, not the row: ClickHouse before 26 refuses an
21
+ // empty scalar subquery of a tuple, which cannot be Nullable.
22
+ const physicalTime = `(SELECT ${dialect.rowElement(source.rowAlias, 1)} FROM _hq_raw LIMIT 0)`;
20
23
  const physicalGuard = axis.grain === 'minute' || axis.grain === 'hour'
21
24
  ? dialect.guard(dialect.isDateOnlyType(physicalTime), 'Sub-day time measures require a time-of-day column; Date and Date32 are not supported.')
22
25
  : '0';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypequery/datasets",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Code-first TypeScript semantic layer for ClickHouse datasets, metrics, multi-tenancy, and AI agents",
5
5
  "keywords": [
6
6
  "semantic-layer",
@@ -55,7 +55,7 @@
55
55
  "!dist/**/type-tests/**"
56
56
  ],
57
57
  "dependencies": {
58
- "@hypequery/protocol": "^0.24.2",
58
+ "@hypequery/protocol": "^0.25.0",
59
59
  "@noble/hashes": "^2.4.0",
60
60
  "zod": "^4.6.6",
61
61
  "zod-to-json-schema": "^3.25.2"
@@ -69,11 +69,11 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@types/node": "^18.19.80",
72
+ "@types/node": "^26.6.6",
73
73
  "typescript": "^6.0.3",
74
- "@vitest/coverage-v8": "^5.0.5",
75
- "vitest": "^5.0.5",
76
- "@hypequery/protocol-conformance": "^0.17.0"
74
+ "@vitest/coverage-v8": "^5.1.0",
75
+ "vitest": "^5.1.0",
76
+ "@hypequery/protocol-conformance": "^0.17.1"
77
77
  },
78
78
  "repository": {
79
79
  "type": "git",