-
-
Notifications
You must be signed in to change notification settings - Fork 220
Open
Description
Describe the bug
Typescript type for Select.distinct does not match runtime value when parsing Snowflake SQL.
Database Engine
Snowflake
To Reproduce
node-sql-parser version: 5.3.4
node version: 22.11.0
parser.astify('SELECT * from foo;', {database: 'Snowflake'});
[
{
with: null,
type: 'select',
options: null,
distinct: { type: null },
columns: [ [Object] ],
into: { position: null },
from: [ [Object] ],
where: null,
groupby: null,
having: null,
qualify: null,
orderby: null,
top: null,
limit: { seperator: '', value: [] },
window: null
}
]
Expected behavior
Declared type as follows. Note that distinct should be the string DISTINCT or null, but is {type: null} at runtime.
export interface Select {
with: With[] | null;
type: "select";
options: any[] | null;
distinct: "DISTINCT" | null;
columns: any[] | Column[];
from: From[] | TableExpr | null ;
where: Binary | Function | null;
groupby: { columns: ColumnRef[] | null, modifiers: ValueExpr<string>[] };
having: any[] | null;
orderby: OrderBy[] | null;
limit: Limit | null;
window?: WindowExpr;
qualify?: any[] | null;
_orderby?: OrderBy[] | null;
_limit?: Limit | null;
parentheses_symbol?: boolean;
_parentheses?: boolean;
loc?: LocationRange;
_next?: Select;
set_op?: string;
}
As a side note, there are some other mismatched/broken types in here. Examples include:
optionsis any-typed. Can we strongly type it?columnsis carrying anany[]option - can we eliminate that in favor of strong typing?groupbyis declared as being a mandatory object, but we seenullat runtime.havingis any-typed. Can we strongly type it?qualifyis declared asany[] | null | undefined. Why does that field support bothnullandundefinedwhen the others don't? Can we strongly type theany[]away?limitis returned with a useless object at runtime, but should probably benull?windowis declared aswindow?: WindowExpr, but we seenullat runtime. Maybe fix the type to bewindow: WindowExpr | nullto match the other fields?- Why have both
_limitandlimit? Same withorderbyand_orderby?
Metadata
Metadata
Assignees
Labels
No labels