Reported March 2026
Retooldesign

Execute In-Memory SQL Queries

Reported by candidates from Retool's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Retool OA. Under 2s to a working solution.
Founder's read

Retool reportedly asked this one in March 2026, and the detail that matters is the ERROR rule: a failed operation changes no state. It's called Execute In-Memory SQL Queries, but there's no SQL parsing anywhere. You get five parallel arrays and up to 100000 operations, and you simulate a tiny database with nested hash maps. It's a design and simulation problem dressed up as something scarier. If you've got an OA invite, read the six operations once and you've got the whole spec. StealthCoder sits invisibly on your screen as a safety net if you blank on the structure during the live OA.

The problem

Execute a finite ordered batch against an in-memory database service. The five input arrays have equal length. Return one result per operation.
CREATE_DB creates a database.
CREATE_TABLE creates a table in an existing database.
INSERT stores values[i] at a new integer row ID.
READ returns the current value for an existing row.
UPDATE replaces the value of an existing row.
DELETE removes an existing row.
A successful write returns OK. A missing parent, missing row, or duplicate create/insert returns ERROR and changes no state. Fields unused by an operation may contain the empty value for their type.

Function
executeStorageOperations(operations: String[], databases: String[], tables: String[], ids: int[], values: String[]) → String[]

Examples
Example 1
operations = ["CREATE_DB","CREATE_TABLE","INSERT","READ","UPDATE","READ","DELETE","READ"]
databases = ["sales","sales","sales","sales","sales","sales","sales","sales"]
tables = ["","orders","orders","orders","orders","orders","orders","orders"]
ids = [0,0,7,7,7,7,7,7]
values = ["","","new","","paid","","",""]
return = ["OK","OK","OK","new","OK","paid","OK","ERROR"]
The update changes the stored row and deletion removes it.
Example 2
operations = ["CREATE_TABLE","CREATE_DB","CREATE_DB","CREATE_TABLE","INSERT","INSERT"]
databases = ["x","x","x","x","x","x"]
tables = ["t","","","t","t","t"]
ids = [0,0,0,0,1,1]
values = ["","","","","a","b"]
return = ["ERROR","OK","ERROR","OK","OK","ERROR"]
Parents must exist and duplicate creates or inserts fail.
Example 3
operations = []
databases = []
tables = []
ids = []
values = []
return = []
An empty batch has no results.

Constraints
0 <= operations.length <= 100000 and all five arrays have that length.
Every operation is one of the six documented uppercase strings.
Database and table names used by their operations are nonempty and at most 100 characters.
Row IDs are nonnegative, and stored values have at most 1000 characters.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is the data model. Use a map from database name to a map from table name to a map from integer row ID to string value. Every operation is then one or two lookups, so the whole batch runs in O(n). Walk the arrays by index, switch on operations[i], and append exactly one result string per step. The pitfalls are all in the ERROR cases. CREATE_TABLE needs the database to exist. INSERT, READ, UPDATE and DELETE need both parents, and the latter three also need the row. Duplicate CREATE_DB, CREATE_TABLE or INSERT returns ERROR without overwriting anything. Don't treat the empty-string fields as meaningful for operations that ignore them. Example 2 is the one to trace by hand. If you freeze on the nested structure during the live OA, StealthCoder is the hedge that hands you the layout in real time.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Execute In-Memory SQL Queries cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Retool's OA.

Retool reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Execute In-Memory SQL Queries FAQ

How hard is the Retool in-memory SQL queries question really?+

Easy to medium. There's no real SQL and no clever algorithm. It's a careful simulation with nested hash maps. Most failures come from missing one ERROR case, not from the data structure. Budget your time for edge cases and testing against the three examples.

What's the trick to solving it?+

Nest three maps: database to table to row ID to value. Process operations in order and append one result each. Check parents before acting, and only mutate state after every check passes so failed operations leave nothing changed.

Which ERROR cases do people miss?+

Duplicate CREATE_DB, duplicate CREATE_TABLE, and INSERT on an ID that already exists. Also CREATE_TABLE before its database exists, as in Example 2. UPDATE and DELETE on a missing row must return ERROR too, like the final READ in Example 1.

Does performance matter with 100000 operations?+

Yes, but hash maps give O(1) average per operation, so total time is linear. Avoid scanning lists or copying tables on each step. Don't rebuild structures per operation. Storing values up to 1000 characters is fine by reference.

How do I prepare for this in 48 hours?+

Write the nested-map solution once from scratch, then run the three examples including the empty batch. Practice similar simulation problems like a key-value store or file system. Focus on ordering checks before mutation, since that's where bugs hide.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Retool.

OA at Retool?
Invisible during screen share
Get it