Skip to content

Commit

Permalink
Fix bugs in number generator. (#1643)
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydtabb authored Mar 6, 2024
1 parent 6a3e8f9 commit 4ea3dc1
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions packages/malloy/src/dialect/snowflake/snowflake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,9 @@ export class SnowflakeDialect extends Dialect {
}

sqlGroupSetTable(groupSetCount: number): string {
return `CROSS JOIN (SELECT seq4() as group_set FROM TABLE(GENERATOR(ROWCOUNT => ${
groupSetCount + 1
}))) as group_set`;
return `SELECT index as group_set FROM TABLE(FLATTEN(ARRAY_GENERATE_RANGE(0, ${groupSetCount})))`;
}

/*
// this just returns null in snowflake
select
any_value (t is not null) as av
from
(
select
case
when group_set = 1 then 'one'
end as t
from
(
SELECT
seq4 () as group_set
FROM
TABLE (GENERATOR (ROWCOUNT => 3))
) as tbl
);
*/
sqlAnyValue(groupSet: number, fieldName: string): string {
return `(ARRAY_AGG(CASE WHEN group_set=${groupSet} THEN ${fieldName} END) WITHIN GROUP (ORDER BY ${fieldName} ASC NULLS LAST))[0]`;
}
Expand Down Expand Up @@ -284,8 +263,8 @@ from
throw new Error('not implemented yet');
}

sqlCreateFunctionCombineLastStage(_lastStageName: string): string {
throw new Error('not implemented yet');
sqlCreateFunctionCombineLastStage(lastStageName: string): string {
return `SELECT ARRAY_AGG(OBJECT_CONSTRUCT(*)) FROM ${lastStageName}`;
}

sqlSelectAliasAsStruct(alias: string): string {
Expand Down

0 comments on commit 4ea3dc1

Please sign in to comment.