@malloydata/malloy 0.0.219 → 0.0.220-dev241204170603
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.
- package/dist/connection/base_connection.js +1 -1
- package/dist/dialect/dialect.d.ts +6 -3
- package/dist/dialect/dialect.js +4 -11
- package/dist/dialect/duckdb/dialect_functions.js +1 -1
- package/dist/dialect/duckdb/duckdb.d.ts +4 -4
- package/dist/dialect/duckdb/duckdb.js +10 -16
- package/dist/dialect/duckdb/function_overrides.js +1 -1
- package/dist/dialect/functions/malloy_standard_functions.js +1 -1
- package/dist/dialect/index.d.ts +3 -1
- package/dist/dialect/index.js +3 -1
- package/dist/dialect/mysql/dialect_functions.js +1 -1
- package/dist/dialect/mysql/function_overrides.js +1 -1
- package/dist/dialect/mysql/index.js +1 -1
- package/dist/dialect/mysql/mysql.d.ts +9 -6
- package/dist/dialect/mysql/mysql.js +36 -25
- package/dist/dialect/pg_impl.d.ts +4 -1
- package/dist/dialect/pg_impl.js +11 -1
- package/dist/dialect/postgres/dialect_functions.js +1 -1
- package/dist/dialect/postgres/function_overrides.js +1 -1
- package/dist/dialect/postgres/postgres.d.ts +6 -4
- package/dist/dialect/postgres/postgres.js +27 -12
- package/dist/dialect/snowflake/dialect_functions.js +1 -1
- package/dist/dialect/snowflake/function_overrides.js +1 -1
- package/dist/dialect/snowflake/snowflake.d.ts +5 -3
- package/dist/dialect/snowflake/snowflake.js +76 -20
- package/dist/dialect/standardsql/dialect_functions.js +1 -1
- package/dist/dialect/standardsql/function_overrides.js +1 -1
- package/dist/dialect/standardsql/standardsql.d.ts +5 -3
- package/dist/dialect/standardsql/standardsql.js +16 -101
- package/dist/dialect/tiny_parser.d.ts +41 -0
- package/dist/dialect/tiny_parser.js +126 -0
- package/dist/dialect/trino/dialect_functions.js +1 -1
- package/dist/dialect/trino/function_overrides.js +1 -1
- package/dist/dialect/trino/trino.d.ts +3 -3
- package/dist/dialect/trino/trino.js +40 -16
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -2
- package/dist/lang/ast/expressions/case.js +1 -1
- package/dist/lang/ast/expressions/expr-array-literal.d.ts +9 -0
- package/dist/lang/ast/expressions/expr-array-literal.js +93 -0
- package/dist/lang/ast/expressions/expr-record-literal.d.ts +1 -1
- package/dist/lang/ast/expressions/expr-record-literal.js +56 -28
- package/dist/lang/ast/field-space/join-space-field.d.ts +1 -1
- package/dist/lang/ast/field-space/join-space-field.js +2 -2
- package/dist/lang/ast/field-space/project-field-space.js +1 -1
- package/dist/lang/ast/field-space/reference-field.js +1 -1
- package/dist/lang/ast/field-space/static-space.d.ts +1 -2
- package/dist/lang/ast/field-space/static-space.js +15 -5
- package/dist/lang/ast/field-space/view-field.d.ts +2 -2
- package/dist/lang/ast/index.d.ts +1 -0
- package/dist/lang/ast/index.js +1 -0
- package/dist/lang/ast/query-items/field-declaration.js +25 -11
- package/dist/lang/ast/query-properties/filters.js +0 -2
- package/dist/lang/ast/source-properties/join.js +1 -1
- package/dist/lang/ast/types/binary_operators.js +1 -1
- package/dist/lang/ast/types/dialect-name-space.js +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.js +12 -16
- package/dist/lang/malloy-to-ast.d.ts +1 -1
- package/dist/lang/malloy-to-ast.js +3 -3
- package/dist/lang/parse-log.d.ts +1 -0
- package/dist/lang/test/query.spec.js +6 -0
- package/dist/lang/test/test-translator.js +11 -2
- package/dist/model/malloy_query.d.ts +29 -24
- package/dist/model/malloy_query.js +261 -146
- package/dist/model/malloy_types.d.ts +12 -15
- package/dist/model/malloy_types.js +2 -7
- package/dist/model/materialization/utils.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/lang/parse-log.d.ts
CHANGED
|
@@ -344,6 +344,7 @@ type MessageParameterTypes = {
|
|
|
344
344
|
'or-choices-only': string;
|
|
345
345
|
'sql-in': string;
|
|
346
346
|
'dialect-cast-unsafe-only': string;
|
|
347
|
+
'array-values-incompatible': string;
|
|
347
348
|
};
|
|
348
349
|
export declare const MESSAGE_FORMATTERS: PartialErrorCodeMessageMap;
|
|
349
350
|
export type MessageCode = keyof MessageParameterTypes;
|
|
@@ -684,6 +684,12 @@ describe('query:', () => {
|
|
|
684
684
|
const fields = getFirstSegmentFieldNames(selstar.translator.getQuery(0));
|
|
685
685
|
expect(fields).toEqual(filterdFields);
|
|
686
686
|
});
|
|
687
|
+
test('array in query is passed into fields', () => {
|
|
688
|
+
const selArray = (0, test_translator_1.model) `run: a -> { select: ais }`;
|
|
689
|
+
expect(selArray).toTranslate();
|
|
690
|
+
const fields = getFirstSegmentFieldNames(selArray.translator.getQuery(0));
|
|
691
|
+
expect(fields).toEqual(['ais']);
|
|
692
|
+
});
|
|
687
693
|
test('star error checking', () => {
|
|
688
694
|
expect((0, test_translator_1.markSource) `run: a->{select: ${'zzz'}.*}`).toLog((0, test_translator_1.errorMessage)("No such field as 'zzz'"));
|
|
689
695
|
expect((0, test_translator_1.markSource) `run: ab->{select: b.${'zzz'}.*}`).toLog((0, test_translator_1.errorMessage)("No such field as 'zzz'"));
|
|
@@ -35,6 +35,7 @@ function pretty(thing) {
|
|
|
35
35
|
return (0, util_1.inspect)(thing, { breakLength: 72, depth: Infinity });
|
|
36
36
|
}
|
|
37
37
|
exports.pretty = pretty;
|
|
38
|
+
const intType = { type: 'number', numberType: 'integer' };
|
|
38
39
|
const mockSchema = {
|
|
39
40
|
'aTable': {
|
|
40
41
|
type: 'table',
|
|
@@ -45,7 +46,7 @@ const mockSchema = {
|
|
|
45
46
|
fields: [
|
|
46
47
|
{ type: 'string', name: 'astr' },
|
|
47
48
|
{ type: 'number', name: 'af', numberType: 'float' },
|
|
48
|
-
{
|
|
49
|
+
{ ...intType, name: 'ai' },
|
|
49
50
|
{ type: 'date', name: 'ad' },
|
|
50
51
|
{ type: 'boolean', name: 'abool' },
|
|
51
52
|
{ type: 'timestamp', name: 'ats' },
|
|
@@ -68,11 +69,19 @@ const mockSchema = {
|
|
|
68
69
|
{
|
|
69
70
|
type: 'record',
|
|
70
71
|
name: 'aninline',
|
|
71
|
-
fields: [{
|
|
72
|
+
fields: [{ ...intType, name: 'column' }],
|
|
72
73
|
join: 'one',
|
|
73
74
|
matrixOperation: 'left',
|
|
74
75
|
dialect: 'standardsql',
|
|
75
76
|
},
|
|
77
|
+
{
|
|
78
|
+
type: 'array',
|
|
79
|
+
name: 'ais',
|
|
80
|
+
elementTypeDef: intType,
|
|
81
|
+
join: 'many',
|
|
82
|
+
fields: (0, malloy_types_1.arrayEachFields)(intType),
|
|
83
|
+
dialect: 'standardsql',
|
|
84
|
+
},
|
|
76
85
|
],
|
|
77
86
|
},
|
|
78
87
|
'malloytest.carriers': {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect, DialectFieldList } from '../dialect';
|
|
2
|
-
import { AggregateFunctionType, Annotation, CompiledQuery, Expr, FieldDef, Filtered, FunctionOverloadDef, FunctionParameterDef, JoinRelationship, ModelDef, OrderBy, OutputFieldNode, ParameterNode, PipeSegment, Query, QueryFieldDef, QuerySegment, ResultMetadataDef, ResultStructMetadataDef, SearchIndexResult, SegmentFieldDef, StructDef, StructRef, TurtleDef, FunctionOrderBy, Argument, AggregateExpr, FilterCondition, GenericSQLExpr, FieldnameNode, FunctionCallNode, UngroupNode, SourceReferenceNode, SpreadExpr, FilteredExpr, SourceDef,
|
|
2
|
+
import { AggregateFunctionType, Annotation, CompiledQuery, Expr, FieldDef, Filtered, FunctionOverloadDef, FunctionParameterDef, JoinRelationship, ModelDef, OrderBy, OutputFieldNode, ParameterNode, PipeSegment, Query, QueryFieldDef, QuerySegment, ResultMetadataDef, ResultStructMetadataDef, SearchIndexResult, SegmentFieldDef, StructDef, StructRef, TurtleDef, FunctionOrderBy, Argument, AggregateExpr, FilterCondition, GenericSQLExpr, FieldnameNode, FunctionCallNode, UngroupNode, SourceReferenceNode, SpreadExpr, FilteredExpr, SourceDef, BooleanFieldDef, QueryResultDef, QueryToMaterialize, PrepareResultOptions, CaseExpr, LeafAtomicDef } from './malloy_types';
|
|
3
3
|
import { Connection } from '../connection/types';
|
|
4
4
|
import { AndChain } from './utils';
|
|
5
5
|
import { QueryInfo } from '../dialect/dialect';
|
|
@@ -46,7 +46,6 @@ declare class StageWriter {
|
|
|
46
46
|
generateSQLStages(): string;
|
|
47
47
|
generateCoorelatedSubQuery(dialect: Dialect, structDef: StructDef): string;
|
|
48
48
|
}
|
|
49
|
-
type QuerySomething = QueryField | QueryStruct | QueryTurtle;
|
|
50
49
|
declare class GenerateState {
|
|
51
50
|
whereSQL?: string;
|
|
52
51
|
applyValue?: string;
|
|
@@ -59,7 +58,7 @@ declare abstract class QueryNode {
|
|
|
59
58
|
readonly referenceId: string;
|
|
60
59
|
constructor(referenceId?: string);
|
|
61
60
|
abstract getIdentifier(): string;
|
|
62
|
-
getChildByName(_name: string):
|
|
61
|
+
getChildByName(_name: string): QueryField | undefined;
|
|
63
62
|
}
|
|
64
63
|
declare class QueryField extends QueryNode {
|
|
65
64
|
fieldDef: FieldDef;
|
|
@@ -68,6 +67,7 @@ declare class QueryField extends QueryNode {
|
|
|
68
67
|
getIdentifier(): string;
|
|
69
68
|
uniqueKeyPossibleUse(): UniqueKeyPossibleUse | undefined;
|
|
70
69
|
getJoinableParent(): QueryStruct;
|
|
70
|
+
isAtomic(): boolean;
|
|
71
71
|
caseGroup(groupSets: number[], s: string): string;
|
|
72
72
|
getFullOutputName(): string;
|
|
73
73
|
generateFieldFragment(resultSet: FieldInstanceResult, context: QueryStruct, expr: FieldnameNode, state: GenerateState): string;
|
|
@@ -96,10 +96,10 @@ declare class QueryField extends QueryNode {
|
|
|
96
96
|
exprToSQL(resultSet: FieldInstanceResult, context: QueryStruct, exprToTranslate: Expr, state?: GenerateState): string;
|
|
97
97
|
isNestedInParent(parentDef: FieldDef): boolean;
|
|
98
98
|
isArrayElement(parentDef: FieldDef): boolean;
|
|
99
|
-
getExpr(): Expr;
|
|
100
99
|
generateExpression(resultSet: FieldInstanceResult): string;
|
|
101
100
|
}
|
|
102
|
-
|
|
101
|
+
type QueryFieldAtomic = AbstractQueryAtomic<LeafAtomicDef>;
|
|
102
|
+
declare class AbstractQueryAtomic<T extends LeafAtomicDef> extends QueryField {
|
|
103
103
|
fieldDef: T;
|
|
104
104
|
constructor(fieldDef: T, parent: QueryStruct, refId?: string);
|
|
105
105
|
includeInWildcard(): boolean;
|
|
@@ -107,8 +107,9 @@ declare class QueryAtomicField<T extends AtomicFieldDef> extends QueryField {
|
|
|
107
107
|
isAggregate(): boolean;
|
|
108
108
|
getFilterList(): FilterCondition[];
|
|
109
109
|
hasExpression(): boolean;
|
|
110
|
+
isAtomic(): boolean;
|
|
110
111
|
}
|
|
111
|
-
declare class QueryFieldBoolean extends
|
|
112
|
+
declare class QueryFieldBoolean extends AbstractQueryAtomic<BooleanFieldDef> {
|
|
112
113
|
}
|
|
113
114
|
type FieldUsage = {
|
|
114
115
|
type: 'result';
|
|
@@ -215,9 +216,6 @@ declare class JoinInstance {
|
|
|
215
216
|
forceAllSymmetricCalculations(): boolean;
|
|
216
217
|
getDialectFieldList(): DialectFieldList;
|
|
217
218
|
}
|
|
218
|
-
/** nested query */
|
|
219
|
-
declare class QueryTurtle extends QueryField {
|
|
220
|
-
}
|
|
221
219
|
/**
|
|
222
220
|
* Used by the translator to get the output StructDef of a pipe segment
|
|
223
221
|
*
|
|
@@ -254,9 +252,10 @@ declare class QueryQuery extends QueryField {
|
|
|
254
252
|
inNestedPipeline(): boolean;
|
|
255
253
|
expandField(f: QueryFieldDef): {
|
|
256
254
|
as: string;
|
|
257
|
-
field:
|
|
255
|
+
field: QueryField;
|
|
258
256
|
};
|
|
259
257
|
addDependantPath(resultStruct: FieldInstanceResult, context: QueryStruct, path: string[], uniqueKeyPossibleUse: UniqueKeyPossibleUse | undefined, joinStack: string[]): void;
|
|
258
|
+
findRecordAliases(context: QueryStruct, path: string[]): void;
|
|
260
259
|
addDependantExpr(resultStruct: FieldInstanceResult, context: QueryStruct, e: Expr, joinStack: string[]): void;
|
|
261
260
|
addDependancies(resultStruct: FieldInstanceResult, field: QueryField): void;
|
|
262
261
|
getSegmentFields(resultStruct: FieldInstanceResult): SegmentFieldDef[];
|
|
@@ -268,7 +267,7 @@ declare class QueryQuery extends QueryField {
|
|
|
268
267
|
getResultMetadata(fi: FieldInstance): ResultStructMetadataDef | ResultMetadataDef | undefined;
|
|
269
268
|
/** returns a fields and primary key of a struct for this query */
|
|
270
269
|
getResultStructDef(resultStruct?: FieldInstanceResult, isRoot?: boolean): QueryResultDef;
|
|
271
|
-
generateSQLJoinBlock(stageWriter: StageWriter, ji: JoinInstance): string;
|
|
270
|
+
generateSQLJoinBlock(stageWriter: StageWriter, ji: JoinInstance, depth: number): string;
|
|
272
271
|
generateSQLPassthroughKeys(qs: QueryStruct): string;
|
|
273
272
|
generateSQLJoins(stageWriter: StageWriter): string;
|
|
274
273
|
genereateSQLOrderBy(queryDef: QuerySegment, resultStruct: FieldInstanceResult): string;
|
|
@@ -296,17 +295,19 @@ declare class QueryQuery extends QueryField {
|
|
|
296
295
|
};
|
|
297
296
|
}
|
|
298
297
|
/** Structure object as it is used to build a query */
|
|
299
|
-
declare class QueryStruct
|
|
298
|
+
declare class QueryStruct {
|
|
300
299
|
structDef: StructDef;
|
|
301
300
|
readonly sourceArguments: Record<string, Argument> | undefined;
|
|
302
301
|
readonly prepareResultOptions: PrepareResultOptions;
|
|
303
302
|
parent: QueryStruct | undefined;
|
|
304
303
|
model: QueryModel;
|
|
305
|
-
nameMap: Map<string,
|
|
304
|
+
nameMap: Map<string, QueryField>;
|
|
306
305
|
pathAliasMap: Map<string, string>;
|
|
307
306
|
dialect: Dialect;
|
|
308
307
|
connectionName: string;
|
|
309
|
-
|
|
308
|
+
recordAlias?: string;
|
|
309
|
+
constructor(structDef: StructDef, sourceArguments: Record<string, Argument> | undefined, parent: ParentQueryStruct | ParentQueryModel, prepareResultOptions: PrepareResultOptions);
|
|
310
|
+
informOfAliasValue(av: string): void;
|
|
310
311
|
maybeEmitParameterizedSourceUsage(): void;
|
|
311
312
|
private resolveParentParameterReferences;
|
|
312
313
|
private _arguments;
|
|
@@ -314,14 +315,18 @@ declare class QueryStruct extends QueryNode {
|
|
|
314
315
|
private addFieldsFromFieldList;
|
|
315
316
|
getAliasIdentifier(): string;
|
|
316
317
|
getSQLIdentifier(): string;
|
|
318
|
+
sqlChildReference(name: string, expand: {
|
|
319
|
+
result: FieldInstanceResult;
|
|
320
|
+
field: QueryField;
|
|
321
|
+
} | undefined): string;
|
|
317
322
|
getIdentifier(): string;
|
|
318
323
|
getFullOutputName(): string;
|
|
319
324
|
needsSymetricCalculation(resultSet: FieldInstanceResult): boolean;
|
|
320
325
|
unnestWithNumbers(): boolean;
|
|
321
326
|
getJoinableParent(): QueryStruct;
|
|
322
|
-
addFieldToNameMap(as: string, n:
|
|
327
|
+
addFieldToNameMap(as: string, n: QueryField): void;
|
|
323
328
|
/** the the primary key or throw an error. */
|
|
324
|
-
getPrimaryKeyField(fieldDef: FieldDef):
|
|
329
|
+
getPrimaryKeyField(fieldDef: FieldDef): QueryFieldAtomic;
|
|
325
330
|
/**
|
|
326
331
|
* called after all structure has been loaded. Examine this structure to see
|
|
327
332
|
* if if it is based on a query and if it is, add the output fields (unless
|
|
@@ -335,18 +340,18 @@ declare class QueryStruct extends QueryNode {
|
|
|
335
340
|
makeQueryField(field: FieldDef, referenceId?: string): QueryField;
|
|
336
341
|
structSourceSQL(stageWriter: StageWriter): string;
|
|
337
342
|
root(): QueryStruct;
|
|
338
|
-
primaryKey():
|
|
339
|
-
getChildByName(name: string):
|
|
343
|
+
primaryKey(): QueryFieldAtomic | undefined;
|
|
344
|
+
getChildByName(name: string): QueryField | undefined;
|
|
340
345
|
/** convert a path into a field reference */
|
|
341
|
-
getFieldByName(path: string[]):
|
|
342
|
-
getQueryFieldByName(name: string[]):
|
|
343
|
-
getQueryFieldReference(
|
|
344
|
-
getDimensionOrMeasureByName(name: string[]):
|
|
346
|
+
getFieldByName(path: string[]): QueryField;
|
|
347
|
+
getQueryFieldByName(name: string[]): QueryField;
|
|
348
|
+
getQueryFieldReference(path: string[], annotation: Annotation | undefined): QueryField;
|
|
349
|
+
getDimensionOrMeasureByName(name: string[]): QueryField;
|
|
345
350
|
/** returns a query object for the given name */
|
|
346
|
-
getDimensionByName(name: string[]):
|
|
351
|
+
getDimensionByName(name: string[]): QueryFieldAtomic;
|
|
347
352
|
/** returns a query object for the given name */
|
|
348
353
|
getStructByName(name: string[]): QueryStruct;
|
|
349
|
-
getDistinctKey():
|
|
354
|
+
getDistinctKey(): QueryFieldAtomic;
|
|
350
355
|
applyStructFiltersToTurtleDef(turtleDef: TurtleDef | TurtleDefPlus): TurtleDef;
|
|
351
356
|
}
|
|
352
357
|
/** the resulting SQL and the shape of the data at each stage of the pipeline */
|