sql-metadata
sql-metadata copied to clipboard
Return information about which column is joined with which column
When parsing an sql query then the attribute parser.columns_dict returns also information about the join.
E.g. see https://github.com/macbre/sql-metadata/blob/master/test/test_getting_columns.py
{
"select": ["fw1.wiki_id"],
"join": ["fw1.wiki_id", "fw2.wiki_id", "fw2.time_id", "dw.wiki_id"],
"where": [
"fw1.time_id",
"dw.url",
"dw.title",
"fw1.vertical_id",
"fw1.wiki_id",
]
}
The above query is correctly mentioning the 4 fields used in the join operations:
["fw1.wiki_id", "fw2.wiki_id", "fw2.time_id", "dw.wiki_id"]
but it would also be interesting to see also which field is joined with which field. So for the above example it would be interesting to have an output array like:
[
{
"operator" : "=",
"left_hand_side" : ["fw1.wiki_id"],
"right_hand_side": ["fw2.wiki_id"]
},
{
"operator" : "=",
"left_hand_side" : ["fw1.wiki_id"],
"right_hand_side": ["dw.wiki_id"]
}
]