code: func resolveWindowSpec(spec *ast.WindowSpec, specs map[string]ast.WindowSpec, inStack map[string]bool) error {
  	if inStack[spec.Name.L] {
  		return errors.Trace(ErrWindowCircularityInWindowGraph)
  	}
  	if spec.Ref.L == "" {
  		return nil
  	}
  	ref, ok := specs[spec.Ref.L]
  	if !ok {
  		return ErrWindowNoSuchWindow.GenWithStackByArgs(spec.Ref.O)
  	}
  	inStack[spec.Name.L] = true
  	err := resolveWindowSpec(&ref, specs, inStack)
  	if err != nil {
  		return err
  	}
  	inStack[spec.Name.L] = false
  	return mergeWindowSpec(spec, &ref)
  }
docs: // resolveWindowSpec resolve window specifications for sql like `select ... from t window w1 as (w2), w2 as (partition by a)`.
  // We need to resolve the referenced window to get the definition of current window spec.