Inner join tables

Write codeMedium25 minDatabricks and Snowflake style

Your task

Implement an inner join of two tables represented as lists of dicts. 'left' rows and 'right' rows are joined on a shared key field name 'key'. For each matching pair, produce a merged dict containing all keys from the left row plus all non-'key' fields from the right row; if a non-'key' field name collides, the right value wins. Return the joined rows ordered first by the order the matching left row appears, then by the order the matching right row appears. Either table may be empty.

Examples

inner_join(left: list[dict], right: list[dict]) -> list[dict]
Example 1
Inputinner_join([{"key": 1, "name": "a"}, {"key": 2, "name": "b"}], [{"key": 1, "age": 30}, {"key": 3, "age": 40}])
Output
keynameage
1a30