Skip to content

Commit

Permalink
Merge pull request #2109 from taozhi8833998/refactor-function-loc-all…
Browse files Browse the repository at this point in the history
…-dialects

refactor: add loc property to func_call in all dialects
  • Loading branch information
taozhi8833998 authored Sep 11, 2024
2 parents 1dc6f55 + 11bd1bc commit 8dc3c89
Show file tree
Hide file tree
Showing 15 changed files with 245 additions and 94 deletions.
25 changes: 17 additions & 8 deletions pegjs/athena.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ call_stmt
ast: {
type: 'call',
expr: e
}
},
...getLocationObject(),
}
}

Expand Down Expand Up @@ -2044,15 +2045,17 @@ func_call
type: 'function',
name: { name: [{ type: 'origin', value: name }] },
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
/ extract_func
/ f:scalar_time_func __ up:on_update_current_timestamp? {
return {
type: 'function',
name: { name: [{ type: 'origin', value: f }] },
over: up
over: up,
...getLocationObject(),
}
}
/ name:(KW_DATE / KW_TIME / KW_TIMESTAMP / 'AT TIME ZONE'i) __ l:or_and_where_expr? __ bc:over_partition? {
Expand All @@ -2063,6 +2066,7 @@ func_call
args: l ? l: { type: 'expr_list', value: [] },
over: bc,
args_parentheses: false,
...getLocationObject(),
};
}
/ name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? {
Expand All @@ -2071,7 +2075,8 @@ func_call
type: 'function',
name: name,
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
extract_filed
Expand All @@ -2088,7 +2093,8 @@ extract_func
field: f,
cast_type: t,
source: s,
}
},
...getLocationObject(),
}
}
/ kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN {
Expand All @@ -2098,7 +2104,8 @@ extract_func
args: {
field: f,
source: s,
}
},
...getLocationObject(),
}
}
scalar_time_func
Expand Down Expand Up @@ -2657,14 +2664,16 @@ proc_func_call
args: {
type: 'expr_list',
value: l
}
},
...getLocationObject(),
};
}
/ name:proc_func_name {
return {
type: 'function',
name: name,
args: null
args: null,
...getLocationObject(),
};
}

Expand Down
25 changes: 17 additions & 8 deletions pegjs/bigquery.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,16 @@ proc_func_call
args: {
type: 'expr_list',
value: l
}
},
...getLocationObject(),
};
}
/ name:proc_func_name {
return {
type: 'function',
name: name,
args: null
args: null,
...getLocationObject(),
};
}

Expand Down Expand Up @@ -2656,14 +2658,16 @@ func_call
type: 'function',
name: { name: [{ type: 'default', value: name }] },
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
/ f:scalar_time_func __ up:on_update_current_timestamp? {
return {
type: 'function',
name: { name: [{ type: 'origin', value: f }] },
over: up
over: up,
...getLocationObject(),
}
}
/ name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? {
Expand All @@ -2672,7 +2676,8 @@ func_call
type: 'function',
name: name,
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}

Expand Down Expand Up @@ -2709,7 +2714,8 @@ any_value_func
expr: e,
having: h
},
over: bc
over: bc,
...getLocationObject(),
}
}

Expand All @@ -2728,7 +2734,8 @@ extract_func
field: f,
cast_type: t,
source: s,
}
},
...getLocationObject(),
}
}
/ kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN {
Expand All @@ -2737,7 +2744,8 @@ extract_func
args: {
field: f,
source: s,
}
},
...getLocationObject(),
}
}
/ 'DATE_TRUNC'i __ LPAREN __ e:expr __ COMMA __ f:extract_filed __ RPAREN {
Expand All @@ -2746,6 +2754,7 @@ extract_func
name: { name: [{ type: 'origin', value: 'date_trunc' }]},
args: { type: 'expr_list', value: [e, { type: 'origin', value: f }] },
over: null,
...getLocationObject(),
};
}

Expand Down
13 changes: 9 additions & 4 deletions pegjs/db2.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -2028,14 +2028,16 @@ func_call
type: 'function',
name: { name: [{ type: 'default', value: name }] },
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
/ f:scalar_time_func __ up:on_update_current_timestamp? {
return {
type: 'function',
name: { name: [{ type: 'origin', value: f }] },
over: up
over: up,
...getLocationObject(),
}
}
/ name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? {
Expand All @@ -2045,6 +2047,7 @@ func_call
name: name,
args: l ? l: { type: 'expr_list', value: [] },
over: bc,
...getLocationObject(),
};
}
scalar_time_func
Expand Down Expand Up @@ -2585,14 +2588,16 @@ proc_func_call
args: {
type: 'expr_list',
value: l
}
},
...getLocationObject(),
};
}
/ name:proc_func_name {
return {
type: 'function',
name: name,
args: null
args: null,
...getLocationObject(),
};
}

Expand Down
24 changes: 18 additions & 6 deletions pegjs/flinksql.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,7 @@ position_func_clause
name: { name: [{ type: 'origin', value: 'position' }]},
separator: ' ',
args,
...getLocationObject(),
};
}

Expand All @@ -2955,6 +2956,7 @@ json_object_func_clause
type: 'function',
name: { name: [{ type: 'origin', value: 'json_object' }]},
args,
...getLocationObject(),
};
}

Expand Down Expand Up @@ -2983,6 +2985,7 @@ trim_func_clause
type: 'function',
name: { name: [{ type: 'origin', value: 'trim' }]},
args,
...getLocationObject(),
};
}

Expand All @@ -3008,6 +3011,7 @@ overlay_func_clause
name: { name: [{ type: 'origin', value: 'overlay' }]},
separator: ' ',
args,
...getLocationObject(),
};
}

Expand All @@ -3033,6 +3037,7 @@ substring_func_clause
name: { name: [{ type: 'origin', value: 'substring' }]},
separator: ' ',
args,
...getLocationObject(),
};
}

Expand All @@ -3047,7 +3052,8 @@ func_call
type: 'function',
name: { name: [{ type: 'default', value: name }] },
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
/ extract_func
Expand All @@ -3056,7 +3062,8 @@ func_call
return {
type: 'function',
name: { name: [{ type: 'origin', value: f }] },
over: up
over: up,
...getLocationObject(),
}
}
/ name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? {
Expand All @@ -3067,6 +3074,7 @@ func_call
name: name,
args: l ? l: { type: 'expr_list', value: [] },
over: bc,
...getLocationObject(),
};
}

Expand All @@ -3084,7 +3092,8 @@ extract_func
field: f,
cast_type: t,
source: s,
}
},
...getLocationObject(),
}
}
/ kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN {
Expand All @@ -3093,7 +3102,8 @@ extract_func
args: {
field: f,
source: s,
}
},
...getLocationObject(),
}
}
scalar_time_func
Expand Down Expand Up @@ -3715,15 +3725,17 @@ proc_func_call
args: {
type: 'expr_list',
value: l
}
},
...getLocationObject(),
};
}
/ name:proc_func_name {
// => IGNORE
return {
type: 'function',
name: name,
args: null
args: null,
...getLocationObject(),
};
}

Expand Down
16 changes: 11 additions & 5 deletions pegjs/hive.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -2020,14 +2020,16 @@ func_call
type: 'function',
name: { name: [{ type: 'default', value: name }] },
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
/ f:scalar_time_func __ up:on_update_current_timestamp? {
return {
type: 'function',
name: { name: [{ type: 'origin', value: f }] },
over: up
over: up,
...getLocationObject(),
}
}
/ name:(KW_DATE / KW_TIME / KW_TIMESTAMP / 'AT TIME ZONE'i) __ l:or_and_where_expr? __ bc:over_partition? {
Expand All @@ -2038,6 +2040,7 @@ func_call
args: l ? l: { type: 'expr_list', value: [] },
over: bc,
args_parentheses: false,
...getLocationObject(),
};
}
/ name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? {
Expand All @@ -2046,7 +2049,8 @@ func_call
type: 'function',
name: name,
args: l ? l: { type: 'expr_list', value: [] },
over: bc
over: bc,
...getLocationObject(),
};
}
scalar_time_func
Expand Down Expand Up @@ -2591,14 +2595,16 @@ proc_func_call
args: {
type: 'expr_list',
value: l
}
},
...getLocationObject(),
};
}
/ name:proc_func_name {
return {
type: 'function',
name: name,
args: null
args: null,
...getLocationObject(),
};
}

Expand Down
Loading

0 comments on commit 8dc3c89

Please sign in to comment.