Design a queries search object that reads one line (a string) at a time. If the string has the form "Q: hello world", it is a query whose content is "hello world"; if it has the form "L: hello morning world", it is a log whose content is "hello morning world". Each time you read a query, store its content and assign it a query id. Each time you read a log, return the ids of all queries that appear in that log. A query appears in a log if every word of the query occurs in the log.
Asked in the coding round 1 stage. Follow-ups may require repeated query words to occur at least as many times in the log, or may treat words as simple presence checks.
input_messages(line_no, raw_line) as the input.log_line_no and matching_query_ids.log_line_no.| Column | Type | Description |
|---|---|---|
| line_noPK | INT | Input sequence number |
| raw_line | VARCHAR(255) | Raw query or log message |