@malloydata/malloy 0.0.225-dev241217223852 → 0.0.225-dev241219181305

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.
@@ -262,6 +262,18 @@ describe('expressions', () => {
262
262
  }
263
263
  `).toLog((0, test_translator_1.errorMessage)('Filtered expression requires an aggregate computation'));
264
264
  });
265
+ test('can use calculate with partition by in select', () => {
266
+ expect((0, test_translator_1.markSource) `
267
+ ##! experimental { partition_by function_order_by }
268
+ run: a -> {
269
+ select: ai, astr
270
+ calculate: prev is lag(ai) {
271
+ partition_by: astr
272
+ order_by: ai asc
273
+ }
274
+ order_by: ai asc, astr asc
275
+ }`).toTranslate();
276
+ });
265
277
  describe('expr props', () => {
266
278
  test('aggregate order by not allowed without experiments enabled', () => {
267
279
  expect((0, test_translator_1.markSource) `
@@ -4,6 +4,7 @@ import { Connection } from '../connection/types';
4
4
  import { AndChain } from './utils';
5
5
  import { QueryInfo } from '../dialect/dialect';
6
6
  import { EventStream } from '../runtime_types';
7
+ import { Tag } from '../tags';
7
8
  interface TurtleDefPlus extends TurtleDef, Filtered {
8
9
  }
9
10
  /** Parent from QueryStruct. */
@@ -307,6 +308,8 @@ declare class QueryStruct {
307
308
  connectionName: string;
308
309
  recordAlias?: string;
309
310
  constructor(structDef: StructDef, sourceArguments: Record<string, Argument> | undefined, parent: ParentQueryStruct | ParentQueryModel, prepareResultOptions: PrepareResultOptions);
311
+ private _modelTag;
312
+ modelCompilerFlags(): Tag;
310
313
  protected findFirstDialect(): string;
311
314
  informOfAliasValue(av: string): void;
312
315
  maybeEmitParameterizedSourceUsage(): void;
@@ -29,6 +29,7 @@ const standardsql_1 = require("../dialect/standardsql/standardsql");
29
29
  const malloy_types_1 = require("./malloy_types");
30
30
  const utils_1 = require("./utils");
31
31
  const utils_2 = require("./materialization/utils");
32
+ const tags_1 = require("../tags");
32
33
  function pathToCol(path) {
33
34
  return path.map(el => encodeURIComponent(el)).join('/');
34
35
  }
@@ -2443,7 +2444,8 @@ class QueryQuery extends QueryField {
2443
2444
  outputPipelinedSQL: [],
2444
2445
  };
2445
2446
  this.generateStage0Fields(this.rootResult, f, stageWriter);
2446
- if (this.firstSegment.type === 'project') {
2447
+ if (this.firstSegment.type === 'project' &&
2448
+ !this.parent.modelCompilerFlags().has('unsafe_complex_select_query')) {
2447
2449
  throw new Error('PROJECT cannot be used on queries with turtles');
2448
2450
  }
2449
2451
  const groupBy = 'GROUP BY ' + f.dimensionIndexes.join(',') + '\n';
@@ -3061,6 +3063,7 @@ class QueryStruct {
3061
3063
  this.sourceArguments = sourceArguments;
3062
3064
  this.prepareResultOptions = prepareResultOptions;
3063
3065
  this.nameMap = new Map();
3066
+ this._modelTag = undefined;
3064
3067
  this._arguments = undefined;
3065
3068
  this.setParent(parent);
3066
3069
  if ('model' in parent) {
@@ -3081,6 +3084,14 @@ class QueryStruct {
3081
3084
  this.dialect = (0, dialect_1.getDialect)(this.findFirstDialect());
3082
3085
  this.addFieldsFromFieldList(structDef.fields);
3083
3086
  }
3087
+ modelCompilerFlags() {
3088
+ if (this._modelTag === undefined) {
3089
+ const annotation = this.structDef.modelAnnotation;
3090
+ const { tag } = tags_1.Tag.annotationToTag(annotation, { prefix: /^##!\s*/ });
3091
+ this._modelTag = tag;
3092
+ }
3093
+ return this._modelTag;
3094
+ }
3084
3095
  findFirstDialect() {
3085
3096
  if ((0, malloy_types_1.isSourceDef)(this.structDef)) {
3086
3097
  return this.structDef.dialect;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.225-dev241217223852",
3
+ "version": "0.0.225-dev241219181305",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",