You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't quite figure out if it's possible to determine the column names returned by a select statement. I think I've narrowed it down to:
a) If there's an alias I use parsed.tree.stmts[0].stmt.select_stmt.target_list[<x>].res_target.name
b) If there no alias I can use parsed.tree.stmts[0].stmt.select_stmt.target_list[<x>].res_target.val.column_ref.fields.last.string.sval
Is this the best way to achieve this? I think it works, but it seems incredibly clunky... is there an analog for the filter_columns method that would do the same thing?
Thanks!
The text was updated successfully, but these errors were encountered:
@skcuslleb There is no helper that gets the target list column names today - but certainly open to adding one, similar to filter columns. A PR to discuss further would be welcome!
Note that if your goal is to match what Postgres would output this would only work in some cases, as for example, pg_query does not have enough information to resolve "SELECT * FROM table" to a list of the table's column names.
Hi there,
I can't quite figure out if it's possible to determine the column names returned by a select statement. I think I've narrowed it down to:
a) If there's an alias I use
parsed.tree.stmts[0].stmt.select_stmt.target_list[<x>].res_target.name
b) If there no alias I can use
parsed.tree.stmts[0].stmt.select_stmt.target_list[<x>].res_target.val.column_ref.fields.last.string.sval
Is this the best way to achieve this? I think it works, but it seems incredibly clunky... is there an analog for the filter_columns method that would do the same thing?
Thanks!
The text was updated successfully, but these errors were encountered: