Skip to content

Commit

Permalink
Merge pull request #2178 from taozhi8833998/refactor-type-definition
Browse files Browse the repository at this point in the history
refactor: add more type definition
  • Loading branch information
taozhi8833998 authored Oct 18, 2024
2 parents 90636a2 + 0d2395c commit 9377ded
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,19 @@ export interface ValueExpr<T = string | number | boolean> {
value: T;
}

export interface ColumnRef {
export interface ColumnRefItem {
type: "column_ref";
table: string | null;
column: string | { expr: ValueExpr };
loc?: LocationRange;
}
export interface ColumnRefExpr {
type: "expr";
expr: ColumnRefItem;
as: string | null;
}

export type ColumnRef = ColumnRefItem | ColumnRefExpr;
export interface SetList {
column: string;
value: any;
Expand Down Expand Up @@ -214,6 +221,31 @@ export type ExprList = {
value: ExpressionValue[];
loc?: LocationRange;
};

export type PartitionBy = {
type: 'expr';
expr: ColumnRef[];
}[];

export type WindowSpec = {
name: null;
partitionby: PartitionBy;
orderby: OrderBy[] | null;
window_frame_clause: string | null; };

export type AsWindowSpec = string | { window_specification: WindowSpec; parentheses: boolean };

export type NamedWindowExpr = {
name: string;
as_window_specification: AsWindowSpec;
};

export type WindowExpr = {
keyword: 'window';
type: 'window',
expr: NamedWindowExpr[];
};

export interface Select {
with: With[] | null;
type: "select";
Expand All @@ -226,11 +258,15 @@ export interface Select {
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;
}
export interface Insert_Replace {
type: "replace" | "insert";
Expand Down

0 comments on commit 9377ded

Please sign in to comment.