@malloydata/malloy
Advanced tools
Comparing version 0.0.37-dev230525224620 to 0.0.37-dev230526070709
@@ -52,3 +52,3 @@ import { AtomicFieldType as AtomicFieldTypeInner, DialectFragment, Expr, ExtractUnit, Sampling, StructDef, TimeFieldType, TimeValue, TimestampUnit, TypecastFragment } from '../model/malloy_types'; | ||
abstract sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string; | ||
abstract sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean): string; | ||
abstract sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, isInNestedPipeline: boolean): string; | ||
abstract sqlSumDistinctHashedKey(sqlDistinctKey: string): string; | ||
@@ -55,0 +55,0 @@ abstract sqlGenerateUUID(): string; |
@@ -28,3 +28,3 @@ import { DateUnit, Expr, ExtractUnit, Sampling, StructDef, TimeFieldType, TimeValue, TimestampUnit, TypecastFragment } from '../model/malloy_types'; | ||
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string; | ||
sqlUnnestAlias(source: string, alias: string, _fieldList: DialectFieldList, needDistinctKey: boolean): string; | ||
sqlUnnestAlias(source: string, alias: string, _fieldList: DialectFieldList, needDistinctKey: boolean, _isArray: boolean, isInNestedPipeline: boolean): string; | ||
sqlSumDistinctHashedKey(_sqlDistinctKey: string): string; | ||
@@ -31,0 +31,0 @@ sqlGenerateUUID(): string; |
@@ -48,3 +48,3 @@ "use strict"; | ||
this.supportsSumDistinctFunction = true; | ||
this.unnestWithNumbers = false; | ||
this.unnestWithNumbers = true; | ||
this.defaultSampling = { rows: 50000 }; | ||
@@ -116,3 +116,12 @@ this.supportUnnestArrayAgg = true; | ||
// } | ||
sqlUnnestAlias(source, alias, _fieldList, needDistinctKey) { | ||
sqlUnnestAlias(source, alias, _fieldList, needDistinctKey, _isArray, isInNestedPipeline) { | ||
if (this.unnestWithNumbers) { | ||
// Duckdb can't unnest in a coorelated subquery at the moment so we hack it. | ||
const arrayLen = isInNestedPipeline | ||
? '100000' | ||
: `array_length(${source})`; | ||
return `LEFT JOIN (select UNNEST(generate_series(1, | ||
${arrayLen}, | ||
1)) as __row_id) as ${alias} ON ${alias}.__row_id <= array_length(${source})`; | ||
} | ||
//Simulate left joins by guarenteeing there is at least one row. | ||
@@ -137,3 +146,3 @@ if (!needDistinctKey) { | ||
// LTNOTE: hack, in duckdb we can't have structs as tables so we kind of simulate it. | ||
if (fieldName === '__row_id') { | ||
if (!this.unnestWithNumbers && fieldName === '__row_id') { | ||
return `${alias}_outer.__row_id`; | ||
@@ -140,0 +149,0 @@ } |
@@ -28,3 +28,3 @@ import { DateUnit, Expr, ExtractUnit, Sampling, TimeFieldType, TimeValue, TimestampUnit, TypecastFragment } from '../model/malloy_types'; | ||
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string; | ||
sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean): string; | ||
sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, _isInNestedPipeline: boolean): string; | ||
sqlSumDistinctHashedKey(sqlDistinctKey: string): string; | ||
@@ -31,0 +31,0 @@ sqlGenerateUUID(): string; |
@@ -147,3 +147,3 @@ "use strict"; | ||
// } | ||
sqlUnnestAlias(source, alias, fieldList, needDistinctKey, isArray) { | ||
sqlUnnestAlias(source, alias, fieldList, needDistinctKey, isArray, _isInNestedPipeline) { | ||
if (isArray) { | ||
@@ -150,0 +150,0 @@ if (needDistinctKey) { |
@@ -27,3 +27,3 @@ import { Expr, ExtractUnit, Sampling, TimeValue, TimestampUnit, TypecastFragment } from '../model/malloy_types'; | ||
sqlCoaleseMeasuresInline(groupSet: number, fieldList: DialectFieldList): string; | ||
sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean): string; | ||
sqlUnnestAlias(source: string, alias: string, fieldList: DialectFieldList, needDistinctKey: boolean, isArray: boolean, _isInNestedPipeline: boolean): string; | ||
sqlSumDistinctHashedKey(sqlDistinctKey: string): string; | ||
@@ -30,0 +30,0 @@ sqlGenerateUUID(): string; |
@@ -224,3 +224,3 @@ "use strict"; | ||
// | ||
sqlUnnestAlias(source, alias, fieldList, needDistinctKey, isArray) { | ||
sqlUnnestAlias(source, alias, fieldList, needDistinctKey, isArray, _isInNestedPipeline) { | ||
if (isArray) { | ||
@@ -227,0 +227,0 @@ if (needDistinctKey) { |
@@ -226,2 +226,3 @@ import { Dialect, DialectFieldList } from '../dialect'; | ||
static makeQuery(fieldDef: TurtleDef, parentStruct: QueryStruct, stageWriter?: StageWriter | undefined): QueryQuery; | ||
inNestedPipeline(): boolean; | ||
getFieldList(): QueryFieldDef[]; | ||
@@ -228,0 +229,0 @@ expandField(f: QueryFieldDef): { |
{ | ||
"name": "@malloydata/malloy", | ||
"version": "0.0.37-dev230525224620", | ||
"version": "0.0.37-dev230526070709", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
1911016
47603