dependency/sqltypes/plan_value.go
func ResolveRows(pvs []PlanValue, bindVars map[string]*querypb.BindVariable) ([][]Value, error) {
	count, err := rowCount(pvs, bindVars)
	if err != nil {
		return nil, err
	}

	// Allocate the rows.
	rows := make([][]Value, count)
	for i := range rows {
		rows[i] = make([]Value, len(pvs))
	}

	// Using j becasue we're resolving by columns.
	for j, pv := range pvs {
		switch {
		case pv.Key != "":
			bv, err := pv.lookupValue(bindVars)
			if err != nil {
				return nil, err
			}
			for i := range rows {
				rows[i][j] = MakeTrusted(bv.Type, bv.Value)
			}
		case !pv.Value.IsNull():
			for i := range rows {
				rows[i][j] = pv.Value
			}
		case pv.ListKey != "":
			bv, err := pv.lookupList(bindVars)
			if err != nil {
				// This code is unreachable because pvRowCount already checks this.
				return nil, err
			}
			for i := range rows {
				rows[i][j] = MakeTrusted(bv.Values[i].Type, bv.Values[i].Value)
			}
		case pv.Values != nil:
			for i := range rows {
				rows[i][j], err = pv.Values[i].ResolveValue(bindVars)
				if err != nil {
					return nil, err
				}
			}
			// default case is a NULL value, which the row values are already initialized to.
		}
	}
	return rows, nil
}
func ResolveRows(pvs []PlanValue, bindVars map[string]*querypb.BindVariable) ([][]Value, error) {
	count, err := rowCount(pvs, bindVars)
	if err != nil {
		return nil, err
	}

	// Allocate the rows.
	rows := make([][]Value, count)
	for i := range rows {
		rows[i] = make([]Value, len(pvs))
	}

	// Using j becasue we're resolving by columns.
	for j, pv := range pvs {
		switch {
		case pv.Key != "":
			bv, err := pv.lookupValue(bindVars)
			if err != nil {
				return nil, err
			}
			for i := range rows {
				rows[i][j] = MakeTrusted(bv.Type, bv.Value)
			}
		case !pv.Value.IsNull():
			for i := range rows {
				rows[i][j] = pv.Value
			}
		case pv.ListKey != "":
			bv, err := pv.lookupList(bindVars)
			if err != nil {
				// This code is unreachable because pvRowCount already checks this.
				return nil, err
			}
			for i := range rows {
				rows[i][j] = MakeTrusted(bv.Values[i].Type, bv.Values[i].Value)
			}
		case pv.Values != nil:
			for i := range rows {
				rows[i][j], err = pv.Values[i].ResolveValue(bindVars)
				if err != nil {
					return nil, err
				}
			}
			// default case is a NULL value, which the row values are already initialized to.
		}
	}
	return rows, nil
}
// ResolveRows resolves a []PlanValue as rows based on the supplied bindvars.