Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mtoy-googly-moogly committed Nov 27, 2024
1 parent 75c798f commit 05491a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
6 changes: 3 additions & 3 deletions packages/malloy-db-snowflake/src/snowflake_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ class SnowObject extends SnowField {
'SNOWFLAKE SCHEMA PARSER ERROR: Walk through undefined'
);
} else {
if (field) {
// mtoy todo Variant record value
} else {
// If we get multiple type for a field, ignore them, should
// which will do until we support viarant data
if (!field) {
this.fieldMap.set(
path.name,
SnowField.make(path.name, fieldType, this.dialect)
Expand Down
2 changes: 0 additions & 2 deletions packages/malloy/src/dialect/snowflake/snowflake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,8 @@ export class SnowflakeDialect extends Dialect {
isArray: boolean,
_isInNestedPipeline: boolean
): string {
// mtoy todo would like to NOT do this
const as = this.sqlMaybeQuoteIdentifier(alias);
if (isArray) {
const as = this.sqlMaybeQuoteIdentifier(alias);
return `,LATERAL FLATTEN(INPUT => ${source}) AS ${alias}_1, LATERAL (SELECT ${alias}_1.INDEX, object_construct('value', ${alias}_1.value) as value ) as ${as}`;
} else {
// have to have a non empty row or it treats it like an inner join :barf-emoji:
Expand Down
30 changes: 15 additions & 15 deletions test/src/databases/all/compound-atomic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@ describe.each(runtimes.runtimeList)(
const literal = num.toString();
return {node: 'numberLiteral', literal, sql: literal};
}
// this is just a standin for "unknown function"
const arrayLen = {
'duckdb': 'LEN',
'duckdb_wasm': 'LEN',
'motherduck': 'LEN',
'bigquery': 'ARRAY_LENGTH',
'postgres': 'ARRAY_LENGTH',
'presto': 'CARDINALITY',
'trino': 'CARDINALITY',
'mysql': 'JSON_LENGTH',
'snowflake': 'ARRAY_SIZE',
};
const empty = `${databaseName}.sql("SELECT 0 as z")`;
function arraySelectVal(...val: Number[]): string {
const literal: ArrayLiteralNode = {
Expand Down Expand Up @@ -125,9 +113,21 @@ describe.each(runtimes.runtimeList)(
evensObj.map(n => ({n}))
);
});
test('array can be passed to functions', async () => {
const fn = arrayLen[databaseName];
expect(fn).toBeDefined();
test('array can be passed to !function', async () => {
// Used as a standin for "unknown function user might call"
const nameOfArrayLenFunction = {
'duckdb': 'LEN',
'standardsql': 'ARRAY_LENGTH',
'postgres': 'ARRAY_LENGTH',
'presto': 'CARDINALITY',
'trino': 'CARDINALITY',
'mysql': 'JSON_LENGTH',
'snowflake': 'ARRAY_SIZE',
};
const dialect = runtime.dialect.name;
const missing = `Dialect '${dialect}' missing array length function in nameOfArrayLenFunction`;
const fn = nameOfArrayLenFunction[dialect] ?? missing;
expect(fn).not.toEqual(missing);
await expect(
`run: ${evens}->{ select: nby2 is ${fn}!number(evens); } `
).malloyResultMatches(runtime, {nby2: evensObj.length});
Expand Down

0 comments on commit 05491a4

Please sign in to comment.