Airtable formulas interview

  1. Have to define what formulas look like
    • How are formulas (specifically operators) defined
      • How are we delineating column names from other types of objects in the formula
      • ([A] + [B])
      • =SUM(A, B)
      • Whether we will allow both kinds of operators (prefix vs infix)
        • Design decision: allow both kinds of operators
    • What kinds of inputs/outputs can formulas have
      • Do we want to enforce types (raise an error if you’re applying an operation on forbidden types, or fail silently)
  2. How to actually evaluate formulas
    • Storing some internal mapping from operator in names in Airtable to the programmatic operator being applied
      • SUM -> operator.add
    • =SUM([A], 2)”
      • Parsing step:
        1. Extract all function compositions with functions and corresponding inputs from the formula string
        class Function:
            def 
            operator: # type: Callable
            Inputs: List[Union[Function, Literal]]
        Function(sum, [Function(multiply, 3, 3) , 2])
        Def eval(input: Input): If input is Literal: Return input For input in inputs: evaluated_input = eval()
      • How will we extract useful information from this formula string
        • Extracting the function name
        • Detecting whether we’re referencing an existing column, or just using a literal
          • Substituting value from existing column before you can proceed with the rest of the computation

Formula for Column A depends on Column B, and A also references C

Circular dependency - Column A depends on Column B, and formulas for Column B depends on Column A

Formula A: Sum(1, 2) + Sum(B, C)

Sum(Sum(1, 2), Sum(B, C))

  • At some point in the evaluation (maybe at the innermost layer), we need to substitute in values from other columns

  • uid: 202011181541 tags: #airtable #interviews

Date
February 22, 2023