diff --git a/pegjs/athena.pegjs b/pegjs/athena.pegjs index 939909d6..1ad1d73d 100644 --- a/pegjs/athena.pegjs +++ b/pegjs/athena.pegjs @@ -953,7 +953,8 @@ call_stmt ast: { type: 'call', expr: e - } + }, + ...getLocationObject(), } } @@ -2044,7 +2045,8 @@ func_call type: 'function', name: { name: [{ type: 'origin', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } / extract_func @@ -2052,7 +2054,8 @@ func_call 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? { @@ -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? { @@ -2071,7 +2075,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } extract_filed @@ -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 { @@ -2098,7 +2104,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } scalar_time_func @@ -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(), }; } diff --git a/pegjs/bigquery.pegjs b/pegjs/bigquery.pegjs index 850db725..9a67a7da 100644 --- a/pegjs/bigquery.pegjs +++ b/pegjs/bigquery.pegjs @@ -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(), }; } @@ -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? { @@ -2672,7 +2676,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } @@ -2709,7 +2714,8 @@ any_value_func expr: e, having: h }, - over: bc + over: bc, + ...getLocationObject(), } } @@ -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 { @@ -2737,7 +2744,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } / 'DATE_TRUNC'i __ LPAREN __ e:expr __ COMMA __ f:extract_filed __ RPAREN { @@ -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(), }; } diff --git a/pegjs/db2.pegjs b/pegjs/db2.pegjs index 0cd7095b..03907c44 100644 --- a/pegjs/db2.pegjs +++ b/pegjs/db2.pegjs @@ -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? { @@ -2045,6 +2047,7 @@ func_call name: name, args: l ? l: { type: 'expr_list', value: [] }, over: bc, + ...getLocationObject(), }; } scalar_time_func @@ -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(), }; } diff --git a/pegjs/flinksql.pegjs b/pegjs/flinksql.pegjs index 098511f6..b360ef54 100644 --- a/pegjs/flinksql.pegjs +++ b/pegjs/flinksql.pegjs @@ -2929,6 +2929,7 @@ position_func_clause name: { name: [{ type: 'origin', value: 'position' }]}, separator: ' ', args, + ...getLocationObject(), }; } @@ -2955,6 +2956,7 @@ json_object_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'json_object' }]}, args, + ...getLocationObject(), }; } @@ -2983,6 +2985,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -3008,6 +3011,7 @@ overlay_func_clause name: { name: [{ type: 'origin', value: 'overlay' }]}, separator: ' ', args, + ...getLocationObject(), }; } @@ -3033,6 +3037,7 @@ substring_func_clause name: { name: [{ type: 'origin', value: 'substring' }]}, separator: ' ', args, + ...getLocationObject(), }; } @@ -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 @@ -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? { @@ -3067,6 +3074,7 @@ func_call name: name, args: l ? l: { type: 'expr_list', value: [] }, over: bc, + ...getLocationObject(), }; } @@ -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 { @@ -3093,7 +3102,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } scalar_time_func @@ -3715,7 +3725,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } / name:proc_func_name { @@ -3723,7 +3734,8 @@ proc_func_call return { type: 'function', name: name, - args: null + args: null, + ...getLocationObject(), }; } diff --git a/pegjs/hive.pegjs b/pegjs/hive.pegjs index b94066e9..a693dc41 100644 --- a/pegjs/hive.pegjs +++ b/pegjs/hive.pegjs @@ -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? { @@ -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? { @@ -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 @@ -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(), }; } diff --git a/pegjs/mariadb.pegjs b/pegjs/mariadb.pegjs index f1daf2f3..4ed1cf9f 100644 --- a/pegjs/mariadb.pegjs +++ b/pegjs/mariadb.pegjs @@ -3175,7 +3175,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -3184,7 +3185,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } / 'DATE_TRUNC'i __ LPAREN __ e:expr __ COMMA __ f:extract_filed __ RPAREN { @@ -3193,6 +3195,7 @@ extract_func name: { name: [{ type: 'origin', value: 'date_trunc' }]}, args: { type: 'expr_list', value: [e, { type: 'origin', value: f }] }, over: null, + ...getLocationObject(), }; } @@ -3219,6 +3222,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -3229,6 +3233,7 @@ func_call type: 'function', name: { name: [{ type: 'origin', value: 'convert' }] }, args: l, + ...getLocationObject(), }; } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -3236,14 +3241,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 &{ return !reservedFunctionName[name.name[0] && name.name[0].value.toLowerCase()] } __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? { @@ -3254,6 +3261,7 @@ func_call name: name, args: l ? l: { type: 'expr_list', value: [] }, over: bc, + ...getLocationObject(), }; } scalar_time_func @@ -3883,7 +3891,8 @@ proc_func_call_args args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } proc_fun_call_without_args @@ -3891,7 +3900,8 @@ proc_fun_call_without_args return { type: 'function', name: name, - args: null + args: null, + ...getLocationObject(), }; } proc_func_call diff --git a/pegjs/mysql.pegjs b/pegjs/mysql.pegjs index c25a275a..cc8ce18d 100644 --- a/pegjs/mysql.pegjs +++ b/pegjs/mysql.pegjs @@ -3465,7 +3465,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -3474,7 +3475,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } / 'DATE_TRUNC'i __ LPAREN __ e:expr __ COMMA __ f:extract_filed __ RPAREN { @@ -3483,6 +3485,7 @@ extract_func name: { name: [{ type: 'origin', value: 'date_trunc' }]}, args: { type: 'expr_list', value: [e, { type: 'origin', value: f }] }, over: null, + ...getLocationObject(), }; } @@ -3509,6 +3512,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -3519,6 +3523,7 @@ func_call type: 'function', name: { name: [{ type: 'origin', value: 'convert' }] }, args: l, + ...getLocationObject(), }; } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -3526,14 +3531,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 &{ return !reservedFunctionName[name.name[0] && name.name[0].value.toLowerCase()] } __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? { @@ -3543,7 +3550,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } scalar_time_func @@ -4205,7 +4213,8 @@ proc_func_call_args args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } proc_fun_call_without_args @@ -4213,7 +4222,8 @@ proc_fun_call_without_args return { type: 'function', name: name, - args: null + args: null, + ...getLocationObject(), }; } proc_func_call diff --git a/pegjs/noql.pegjs b/pegjs/noql.pegjs index 9cff9b13..fd98953e 100644 --- a/pegjs/noql.pegjs +++ b/pegjs/noql.pegjs @@ -4329,6 +4329,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -4343,7 +4344,9 @@ tablefunc_clause type: 'function', name: { name: [{ type: 'default', value: name }] }, args: { type: 'expr_list', value: cds.map(v => ({ ...v, type: 'column_definition' })) }, - } + ...getLocationObject(), + }, + ...getLocationObject(), } } @@ -4356,7 +4359,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: z + suffix: z, + ...getLocationObject(), }; } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -4365,7 +4369,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 @@ -4374,7 +4379,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 { @@ -4383,7 +4389,8 @@ func_call return { type: 'function', name: name, - args: l ? l: { type: 'expr_list', value: [] } + args: l ? l: { type: 'expr_list', value: [] }, + ...getLocationObject(), }; } @@ -4401,7 +4408,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -4411,7 +4419,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } @@ -5104,7 +5113,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 8a9cb084..487a3a1f 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -4812,6 +4812,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }] }, args, + ...getLocationObject(), }; } @@ -4826,7 +4827,9 @@ tablefunc_clause type: 'function', name: { name: [{ type: 'default', value: d[2] }]}, args: { type: 'expr_list', value: d[6].map(v => ({ ...v, type: 'column_definition' })) }, - } + ...getLocationObject(), + }, + ...getLocationObject(), } } @@ -4839,7 +4842,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: z + suffix: z, + ...getLocationObject(), }; } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -4848,7 +4852,8 @@ func_call type: 'function', name: { name: [{ type: 'origin', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } / extract_func @@ -4857,7 +4862,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 { @@ -4866,7 +4872,8 @@ func_call return { type: 'function', name: name, - args: l ? l: { type: 'expr_list', value: [] } + args: l ? l: { type: 'expr_list', value: [] }, + ...getLocationObject(), }; } @@ -4884,7 +4891,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -4894,7 +4902,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } @@ -5598,7 +5607,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } diff --git a/pegjs/redshift.pegjs b/pegjs/redshift.pegjs index 1fa6d311..df8e4b22 100644 --- a/pegjs/redshift.pegjs +++ b/pegjs/redshift.pegjs @@ -4389,6 +4389,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -4403,7 +4404,9 @@ tablefunc_clause type: 'function', name: { name: [{ type: 'default', value: n }]}, args: { type: 'expr_list', value: cds.map(v => ({ ...v, type: 'column_definition' })) }, - } + ...getLocationObject(), + }, + ...getLocationObject(), } } @@ -4416,7 +4419,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: z + suffix: z, + ...getLocationObject(), }; } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -4425,7 +4429,8 @@ func_call type: 'function', name: { name: [{ type: 'origin', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } / extract_func @@ -4434,7 +4439,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 { @@ -4443,7 +4449,8 @@ func_call return { type: 'function', name: name, - args: l ? l: { type: 'expr_list', value: [] } + args: l ? l: { type: 'expr_list', value: [] }, + ...getLocationObject(), }; } @@ -4461,7 +4468,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -4471,7 +4479,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } @@ -5170,7 +5179,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } diff --git a/pegjs/snowflake.pegjs b/pegjs/snowflake.pegjs index 5762a1e6..a7c66fcb 100644 --- a/pegjs/snowflake.pegjs +++ b/pegjs/snowflake.pegjs @@ -3806,6 +3806,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -3889,7 +3890,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: z + suffix: z, + ...getLocationObject(), }; } / name:'FLATTEN'i __ LPAREN __ l:flattern_args __ RPAREN { @@ -3897,6 +3899,7 @@ func_call type: 'flatten', name: { name: [{ type: 'default', value: name }] }, args: l, + ...getLocationObject(), } } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -3905,7 +3908,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 @@ -3914,7 +3918,8 @@ func_call return { type: 'function', name: { name: [{ type: 'origin', value: f }] }, - over: up + over: up, + ...getLocationObject(), } } / name:'parse_json'i __ LPAREN __ l:or_and_where_expr? __ RPAREN __ j:json_visit_list? { @@ -3924,7 +3929,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: j + suffix: j, + ...getLocationObject(), }; } / name:proc_func_name __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? { @@ -3935,6 +3941,7 @@ func_call name: name, args: l ? l: { type: 'expr_list', value: [] }, over: bc, + ...getLocationObject(), }; } @@ -3952,7 +3959,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -3962,7 +3970,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } @@ -4662,7 +4671,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } / name:proc_func_name { @@ -4670,7 +4680,8 @@ proc_func_call return { type: 'function', name: name, - args: null + args: null, + ...getLocationObject(), }; } diff --git a/pegjs/sqlite.pegjs b/pegjs/sqlite.pegjs index 83a99a7b..0c519d23 100644 --- a/pegjs/sqlite.pegjs +++ b/pegjs/sqlite.pegjs @@ -2359,14 +2359,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? { @@ -2375,7 +2377,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } scalar_time_func @@ -2954,14 +2957,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(), }; } diff --git a/pegjs/transactsql.pegjs b/pegjs/transactsql.pegjs index 765c02e0..5b38c108 100644 --- a/pegjs/transactsql.pegjs +++ b/pegjs/transactsql.pegjs @@ -2713,14 +2713,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? { @@ -2729,7 +2731,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } scalar_time_func @@ -3297,14 +3300,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(), }; } diff --git a/pegjs/trino.pegjs b/pegjs/trino.pegjs index ea0019b9..cfd83c5a 100644 --- a/pegjs/trino.pegjs +++ b/pegjs/trino.pegjs @@ -3805,6 +3805,7 @@ trim_func_clause type: 'function', name: { name: [{ type: 'origin', value: 'trim' }]}, args, + ...getLocationObject(), }; } @@ -3873,7 +3874,8 @@ func_call type: 'function', name: { name: [{ type: 'default', value: name }] }, args: l ? l: { type: 'expr_list', value: [] }, - suffix: z + suffix: z, + ...getLocationObject(), }; } / name:'FLATTEN'i __ LPAREN __ l:flattern_args __ RPAREN { @@ -3881,6 +3883,7 @@ func_call type: 'flatten', name: { name: [{ type: 'default', value: name }] }, args: l, + ...getLocationObject(), } } / name:scalar_func __ LPAREN __ l:expr_list? __ RPAREN __ bc:over_partition? { @@ -3889,7 +3892,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 @@ -3898,7 +3902,8 @@ func_call return { type: 'function', name: { name: [{ type: 'origin', value: f }] }, - over: up + over: up, + ...getLocationObject(), } } / name:proc_func_name &{ return !reservedFunctionName[name.name[0] && name.name[0].value.toLowerCase()] } __ LPAREN __ l:or_and_where_expr? __ RPAREN __ bc:over_partition? { @@ -3908,7 +3913,8 @@ func_call type: 'function', name: name, args: l ? l: { type: 'expr_list', value: [] }, - over: bc + over: bc, + ...getLocationObject(), }; } @@ -3926,7 +3932,8 @@ extract_func field: f, cast_type: t, source: s, - } + }, + ...getLocationObject(), } } / kw:KW_EXTRACT __ LPAREN __ f:extract_filed __ KW_FROM __ s:expr __ RPAREN { @@ -3936,7 +3943,8 @@ extract_func args: { field: f, source: s, - } + }, + ...getLocationObject(), } } @@ -4622,7 +4630,8 @@ proc_func_call args: { type: 'expr_list', value: l - } + }, + ...getLocationObject(), }; } / name:proc_func_name { @@ -4630,7 +4639,8 @@ proc_func_call return { type: 'function', name: name, - args: null + args: null, + ...getLocationObject(), }; } diff --git a/test/postgres.spec.js b/test/postgres.spec.js index 1edbc339..9f92b27b 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -1999,6 +1999,35 @@ describe('Postgres', () => { it('should proc assign', () => { expect(procToSQL({stmt: {type: 'assign', left: {type: 'default', value: 'abc'}, keyword: '', right: {type: 'number', value: 123}, symbol: '='}})).to.be.equal('abc = 123') }) + it('should has loc property', () => { + const sql = 'SELECT * FROM "company" WHERE NOT(company._id IS NULL)' + const opt = { database: 'postgresql', parseOptions: { includeLocations: true } } + const ast = parser.astify(sql, opt) + expect(ast.where.loc).to.be.eql({ + "start": { + "offset": 30, + "line": 1, + "column": 31 + }, + "end": { + "offset": 54, + "line": 1, + "column": 55 + } + }) + expect(ast.where.args.value[0].loc).to.be.eql({ + "start": { + "offset": 34, + "line": 1, + "column": 35 + }, + "end": { + "offset": 53, + "line": 1, + "column": 54 + } + }) + }) it('should throw error', () => { const sql = "select 1 as 'one'" const fun = parser.astify.bind(parser, sql, opt)