@malloydata/malloy
Advanced tools
Comparing version 0.0.222-dev241212154316 to 0.0.222-dev241212190052
@@ -426,3 +426,3 @@ "use strict"; | ||
const fieldType = this.typeDef(); | ||
baseType.fields.push((0, malloy_types_1.mkFieldDef)(fieldType, this.unquoteName(fieldName), 'duckdb')); | ||
baseType.fields.push((0, malloy_types_1.mkFieldDef)(fieldType, this.unquoteName(fieldName))); | ||
} | ||
@@ -429,0 +429,0 @@ else { |
@@ -51,3 +51,10 @@ import { FunctionParameterDef, TypeDesc, Expr, FunctionParamTypeDesc, LeafExpressionType } from '../../model/malloy_types'; | ||
}): DialectFunctionOverloadDef; | ||
export type TypeDescBlueprint = LeafExpressionType | { | ||
export interface ArrayBlueprint { | ||
array: TypeDescElementBlueprint; | ||
} | ||
export interface RecordBlueprint { | ||
record: Record<string, TypeDescElementBlueprint>; | ||
} | ||
export type TypeDescElementBlueprint = LeafExpressionType | ArrayBlueprint | RecordBlueprint; | ||
export type TypeDescBlueprint = TypeDescElementBlueprint | { | ||
generic: string; | ||
@@ -54,0 +61,0 @@ } | { |
@@ -27,2 +27,3 @@ "use strict"; | ||
const composite_source_utils_1 = require("../../model/composite_source_utils"); | ||
const malloy_types_1 = require("../../model/malloy_types"); | ||
function arg(name) { | ||
@@ -120,2 +121,6 @@ return { node: 'function_parameter', name }; | ||
exports.anyExprType = anyExprType; | ||
function anyExprTypeBP(type, generic) { | ||
const typeDesc = expandReturnTypeBlueprint(type, generic); | ||
return { ...typeDesc, expressionType: undefined, evalSpace: 'input' }; | ||
} | ||
function maxUngroupedAggregate(type) { | ||
@@ -170,2 +175,44 @@ return { type, expressionType: 'ungrouped_aggregate', evalSpace: 'input' }; | ||
} | ||
else if ('array' in blueprint) { | ||
const innerType = expandReturnTypeBlueprint(blueprint.array, generic); | ||
const { expressionType, evalSpace } = innerType; | ||
if (malloy_types_1.TD.isAtomic(innerType)) { | ||
if (innerType.type !== 'record') { | ||
base = { | ||
type: 'array', | ||
elementTypeDef: innerType, | ||
expressionType, | ||
evalSpace, | ||
}; | ||
} | ||
else { | ||
base = { | ||
type: 'array', | ||
elementTypeDef: { type: 'record_element' }, | ||
fields: innerType.fields, | ||
expressionType, | ||
evalSpace, | ||
}; | ||
} | ||
} | ||
else { | ||
// mtoy todo fix by doing "exapndElementBlueprint" ... | ||
throw new Error(`TypeDescElementBlueprint should never allow ${blueprint.array}`); | ||
} | ||
} | ||
else if ('record' in blueprint) { | ||
const fields = []; | ||
for (const [fieldName, fieldBlueprint] of Object.entries(blueprint.record)) { | ||
const fieldDesc = expandReturnTypeBlueprint(fieldBlueprint, generic); | ||
if (malloy_types_1.TD.isAtomic(fieldDesc)) { | ||
fields.push((0, malloy_types_1.mkFieldDef)(fieldDesc, fieldName)); | ||
} | ||
} | ||
base = { | ||
type: 'record', | ||
fields, | ||
evalSpace: 'input', | ||
expressionType: 'scalar', | ||
}; | ||
} | ||
else if ('generic' in blueprint) { | ||
@@ -197,2 +244,4 @@ base = minScalar(removeGeneric(blueprint, generic)); | ||
return (typeof blueprint === 'string' || | ||
'array' in blueprint || | ||
'record' in blueprint || | ||
'generic' in blueprint || | ||
@@ -238,2 +287,8 @@ 'literal' in blueprint || | ||
} | ||
else if ('array' in blueprint) { | ||
return anyExprTypeBP(blueprint, generic); | ||
} | ||
else if ('record' in blueprint) { | ||
return anyExprTypeBP(blueprint, generic); | ||
} | ||
else { | ||
@@ -240,0 +295,0 @@ return maxAnalytic(removeGeneric(blueprint.calculation, generic)); |
@@ -242,2 +242,7 @@ "use strict"; | ||
}; | ||
const split = { | ||
takes: { 'src': 'string', 'splitChar': 'string' }, | ||
returns: { array: 'string' }, | ||
impl: { function: 'SPLIT' }, | ||
}; | ||
exports.TRINO_DIALECT_FUNCTIONS = { | ||
@@ -278,3 +283,4 @@ // aggregate functions | ||
percent_rank, | ||
split, | ||
}; | ||
//# sourceMappingURL=dialect_functions.js.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
recLit.kids[el.key] = xVal.value; | ||
recLit.typeDef.fields.push((0, model_1.mkFieldDef)(TDU.atomicDef(xVal), el.key, fs.dialectName())); | ||
recLit.typeDef.fields.push((0, model_1.mkFieldDef)(TDU.atomicDef(xVal), el.key)); | ||
} | ||
@@ -73,0 +73,0 @@ else { |
@@ -61,3 +61,3 @@ "use strict"; | ||
constructor(extending) { | ||
super(structuredClone(extending)); | ||
super(structuredClone(extending), extending.dialect); | ||
this.complete = false; | ||
@@ -64,0 +64,0 @@ this.parameters = []; |
@@ -7,3 +7,3 @@ import { Join } from '../source-properties/join'; | ||
readonly join: Join; | ||
constructor(parameterSpace: ParameterSpace, join: Join); | ||
constructor(parameterSpace: ParameterSpace, join: Join, forDialect: string); | ||
} |
@@ -28,4 +28,4 @@ "use strict"; | ||
class JoinSpaceField extends static_space_1.StructSpaceField { | ||
constructor(parameterSpace, join) { | ||
super(join.structDef(parameterSpace)); | ||
constructor(parameterSpace, join, forDialect) { | ||
super(join.structDef(parameterSpace), forDialect); | ||
this.parameterSpace = parameterSpace; | ||
@@ -32,0 +32,0 @@ this.join = join; |
@@ -81,3 +81,3 @@ "use strict"; | ||
this.queryFieldDef = { | ||
...(0, malloy_types_1.mkFieldDef)(TDU.atomicDef(foundType), path[0], fs.dialectName()), | ||
...(0, malloy_types_1.mkFieldDef)(TDU.atomicDef(foundType), path[0]), | ||
e: { node: 'parameter', path }, | ||
@@ -84,0 +84,0 @@ }; |
@@ -9,7 +9,7 @@ import { Dialect } from '../../../dialect/dialect'; | ||
export declare class StaticSpace implements FieldSpace { | ||
protected fromStruct: StructDef; | ||
readonly type = "fieldSpace"; | ||
private memoMap?; | ||
get dialect(): string; | ||
constructor(fromStruct: StructDef); | ||
protected fromStruct: StructDef; | ||
protected structDialect: string; | ||
constructor(struct: StructDef, dialect_name: string); | ||
dialectName(): string; | ||
@@ -30,3 +30,4 @@ dialectObj(): Dialect | undefined; | ||
export declare class StructSpaceField extends StructSpaceFieldBase { | ||
constructor(def: JoinFieldDef); | ||
private forDialect; | ||
constructor(def: JoinFieldDef, forDialect: string); | ||
get fieldSpace(): FieldSpace; | ||
@@ -33,0 +34,0 @@ } |
@@ -34,15 +34,13 @@ "use strict"; | ||
class StaticSpace { | ||
get dialect() { | ||
return this.fromStruct.dialect; | ||
} | ||
constructor(fromStruct) { | ||
this.fromStruct = fromStruct; | ||
constructor(struct, dialect_name) { | ||
this.type = 'fieldSpace'; | ||
this.fromStruct = struct; | ||
this.structDialect = dialect_name; | ||
} | ||
dialectName() { | ||
return this.fromStruct.dialect; | ||
return this.structDialect; | ||
} | ||
dialectObj() { | ||
try { | ||
return (0, dialect_map_1.getDialect)(this.fromStruct.dialect); | ||
return (0, dialect_map_1.getDialect)(this.structDialect); | ||
} | ||
@@ -55,3 +53,3 @@ catch { | ||
if ((0, malloy_types_1.isJoined)(from)) { | ||
return new StructSpaceField(from); | ||
return new StructSpaceField(from, this.structDialect); | ||
} | ||
@@ -130,3 +128,3 @@ else if ((0, malloy_types_1.isTurtle)(from)) { | ||
// TODO don't make one of these every time you do a lookup | ||
found = new StructSpaceField(definition); | ||
found = new StructSpaceField(definition, this.structDialect); | ||
} | ||
@@ -179,7 +177,13 @@ // cswenson review todo I don't know how to count the reference properly now | ||
class StructSpaceField extends struct_space_field_base_1.StructSpaceFieldBase { | ||
constructor(def) { | ||
constructor(def, forDialect) { | ||
super(def); | ||
this.forDialect = forDialect; | ||
} | ||
get fieldSpace() { | ||
return new StaticSpace(this.structDef); | ||
if ((0, malloy_types_1.isSourceDef)(this.structDef)) { | ||
return new StaticSourceSpace(this.structDef); | ||
} | ||
else { | ||
return new StaticSpace(this.structDef, this.forDialect); | ||
} | ||
} | ||
@@ -190,3 +194,3 @@ } | ||
constructor(source) { | ||
super(source); | ||
super(source, source.dialect); | ||
this.source = source; | ||
@@ -193,0 +197,0 @@ } |
@@ -61,3 +61,3 @@ "use strict"; | ||
: this.source.getSourceDef(undefined); | ||
fieldSpace = new static_space_1.StaticSpace(inputStruct); | ||
fieldSpace = new static_space_1.StaticSourceSpace(inputStruct); | ||
} | ||
@@ -69,3 +69,3 @@ else { | ||
inputStruct = lhsQuery.outputStruct; | ||
fieldSpace = new static_space_1.StaticSpace(lhsQuery.outputStruct); | ||
fieldSpace = new static_space_1.StaticSourceSpace(lhsQuery.outputStruct); | ||
} | ||
@@ -72,0 +72,0 @@ const { pipeline, annotation, outputStruct, name } = this.view.pipelineComp(fieldSpace); |
@@ -43,3 +43,3 @@ "use strict"; | ||
const q = this.base.queryComp(isRefOk); | ||
const inputFS = new static_space_1.StaticSpace(q.inputStruct); | ||
const inputFS = new static_space_1.StaticSourceSpace(q.inputStruct); | ||
const resultPipe = this.refinement.refine(inputFS, q.query.pipeline, undefined); | ||
@@ -46,0 +46,0 @@ return { |
@@ -112,3 +112,3 @@ "use strict"; | ||
this.typecheckExprValue(exprValue); | ||
const ret = (0, malloy_types_1.mkFieldDef)(TDU.atomicDef(exprValue), exprName, exprFS.dialectName()); | ||
const ret = (0, malloy_types_1.mkFieldDef)(TDU.atomicDef(exprValue), exprName); | ||
if ((ret.type === 'date' || ret.type === 'timestamp') && | ||
@@ -115,0 +115,0 @@ (0, granular_result_1.isGranularResult)(exprValue)) { |
@@ -107,3 +107,4 @@ "use strict"; | ||
} | ||
this.logError('invalid-source-source', `Cannot construct a source from a ${entry.type}`); | ||
// I think this is now a never | ||
this.logError('invalid-source-source', 'Cannot construct a source from a never type'); | ||
} | ||
@@ -110,0 +111,0 @@ evaluateArgumentsForRef(parameterSpace) { |
@@ -40,3 +40,3 @@ "use strict"; | ||
makeEntry(fs) { | ||
fs.newEntry(this.name.refString, this, new join_space_field_1.JoinSpaceField(fs.parameterSpace(), this)); | ||
fs.newEntry(this.name.refString, this, new join_space_field_1.JoinSpaceField(fs.parameterSpace(), this, fs.dialectName())); | ||
} | ||
@@ -43,0 +43,0 @@ getStructDefFromExpr(parameterSpace) { |
@@ -43,3 +43,3 @@ "use strict"; | ||
const baseComp = this.base.pipelineComp(fs); | ||
const nextFS = new static_space_1.StaticSpace(baseComp.outputStruct); | ||
const nextFS = new static_space_1.StaticSourceSpace(baseComp.outputStruct); | ||
const finalComp = this.operation.pipelineComp(nextFS); | ||
@@ -46,0 +46,0 @@ return { |
@@ -54,3 +54,3 @@ "use strict"; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -67,3 +67,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -80,3 +80,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -92,3 +92,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -104,3 +104,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -114,3 +114,2 @@ const oField = space.structDef().fields[0]; | ||
type: 'array', | ||
dialect: 'standardsql', | ||
elementTypeDef: { type: 'string' }, | ||
@@ -122,3 +121,3 @@ join: 'many', | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t.b')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -132,3 +131,2 @@ const oField = space.structDef().fields[0]; | ||
type: 'record', | ||
dialect: 'standardsql', | ||
join: 'one', | ||
@@ -139,3 +137,3 @@ matrixOperation: 'left', | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t.a')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -164,3 +162,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t.a')).found).toBeInstanceOf(column_space_field_1.ColumnSpaceField); | ||
@@ -182,3 +180,3 @@ const oField = space.structDef().fields[0]; | ||
const struct = mkStructDef(field); | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('t')).found).toBeInstanceOf(ir_view_field_1.IRViewField); | ||
@@ -202,3 +200,3 @@ const oField = space.structDef().fields[0]; | ||
}; | ||
const space = new static_space_1.StaticSpace(struct); | ||
const space = new static_space_1.StaticSourceSpace(struct); | ||
expect(space.lookup(fieldRef('cReqStr')).found).toBeInstanceOf(space_param_1.DefinedParameter); | ||
@@ -205,0 +203,0 @@ expect(space.lookup(fieldRef('cOptStr')).found).toBeInstanceOf(space_param_1.DefinedParameter); |
@@ -67,3 +67,2 @@ "use strict"; | ||
], | ||
dialect: 'standardsql', | ||
}, | ||
@@ -76,5 +75,4 @@ { | ||
matrixOperation: 'left', | ||
dialect: 'standardsql', | ||
}, | ||
(0, malloy_types_1.mkArrayDef)(intType, 'ais', 'standardsql'), | ||
(0, malloy_types_1.mkArrayDef)(intType, 'ais'), | ||
], | ||
@@ -81,0 +79,0 @@ }, |
@@ -310,2 +310,3 @@ import { Dialect, DialectFieldList } from '../dialect'; | ||
constructor(structDef: StructDef, sourceArguments: Record<string, Argument> | undefined, parent: ParentQueryStruct | ParentQueryModel, prepareResultOptions: PrepareResultOptions); | ||
protected findFirstDialect(): string; | ||
informOfAliasValue(av: string): void; | ||
@@ -312,0 +313,0 @@ maybeEmitParameterizedSourceUsage(): void; |
@@ -392,4 +392,4 @@ /// <reference types="node" /> | ||
} | ||
export declare function mkFieldDef(atd: AtomicTypeDef, name: string, dialect: string): AtomicFieldDef; | ||
export declare function mkArrayDef(ofType: AtomicTypeDef, name: string, dialect: string): ArrayDef; | ||
export declare function mkFieldDef(atd: AtomicTypeDef, name: string): AtomicFieldDef; | ||
export declare function mkArrayDef(ofType: AtomicTypeDef, name: string): ArrayDef; | ||
export interface RecordTypeDef { | ||
@@ -576,3 +576,2 @@ type: 'record'; | ||
fields: FieldDef[]; | ||
dialect: string; | ||
} | ||
@@ -585,2 +584,3 @@ interface SourceDefBase extends StructDefBase, Filtered, ResultStructMetadata { | ||
primaryKey?: PrimaryKeyRef; | ||
dialect: string; | ||
} | ||
@@ -701,3 +701,3 @@ /** which field is the primary key in this struct */ | ||
export declare function getIdentifier(n: AliasedName): string; | ||
export type NamedModelObject = StructDef | NamedQuery | FunctionDef | ConnectionDef; | ||
export type NamedModelObject = SourceDef | NamedQuery | FunctionDef | ConnectionDef; | ||
/** Result of parsing a model file */ | ||
@@ -704,0 +704,0 @@ export interface ModelDef { |
@@ -182,13 +182,13 @@ "use strict"; | ||
exports.fieldIsIntrinsic = fieldIsIntrinsic; | ||
function mkFieldDef(atd, name, dialect) { | ||
function mkFieldDef(atd, name) { | ||
if (isScalarArray(atd)) { | ||
return mkArrayDef(atd.elementTypeDef, name, dialect); | ||
return mkArrayDef(atd.elementTypeDef, name); | ||
} | ||
if (isRepeatedRecord(atd)) { | ||
const { type, fields, elementTypeDef } = atd; | ||
return { type, fields, elementTypeDef, join: 'many', name, dialect }; | ||
return { type, fields, elementTypeDef, join: 'many', name }; | ||
} | ||
if (atd.type === 'record') { | ||
const { type, fields } = atd; | ||
return { type, fields, join: 'one', dialect, name }; | ||
return { type, fields, join: 'one', name }; | ||
} | ||
@@ -198,3 +198,3 @@ return { ...atd, name }; | ||
exports.mkFieldDef = mkFieldDef; | ||
function mkArrayDef(ofType, name, dialect) { | ||
function mkArrayDef(ofType, name) { | ||
if (ofType.type === 'record') { | ||
@@ -205,3 +205,2 @@ return { | ||
name, | ||
dialect, | ||
elementTypeDef: { type: 'record_element' }, | ||
@@ -211,3 +210,3 @@ fields: ofType.fields, | ||
} | ||
const valueEnt = mkFieldDef(ofType, 'value', dialect); | ||
const valueEnt = mkFieldDef(ofType, 'value'); | ||
return { | ||
@@ -217,3 +216,2 @@ type: 'array', | ||
name, | ||
dialect, | ||
elementTypeDef: ofType, | ||
@@ -220,0 +218,0 @@ fields: [ |
{ | ||
"name": "@malloydata/malloy", | ||
"version": "0.0.222-dev241212154316", | ||
"version": "0.0.222-dev241212190052", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "exports": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
3105352
75777