ParseTableNameWithQualifiedNames can be used to parse an input table name that might be prefixed with an unquoted qualified name. The standard ParseTableName cannot do this due to limitations with our parser. In particular, the parser can't parse different productions individually -- it must parse t
(sql string)
| 327 | // with a fake non-keyword prefix, and then shifting the result down into an |
| 328 | // UnresolvedObjectName. |
| 329 | func ParseTableNameWithQualifiedNames(sql string) (*tree.UnresolvedObjectName, error) { |
| 330 | stmt, err := ParseOne(fmt.Sprintf("SELECT fakeprefix.%s", sql)) |
| 331 | if err != nil { |
| 332 | return nil, err |
| 333 | } |
| 334 | un := stmt.AST.(*tree.Select).Select.(*tree.SelectClause).Exprs[0].Expr.(*tree.UnresolvedName) |
| 335 | var nameParts [3]string |
| 336 | numParts := un.NumParts - 1 |
| 337 | for i := 0; i < numParts; i++ { |
| 338 | nameParts[i] = un.Parts[i] |
| 339 | } |
| 340 | return tree.NewUnresolvedObjectName(numParts, nameParts, 0 /* annotationIdx */) |
| 341 | } |
| 342 | |
| 343 | // parseExprs parses one or more sql expressions. |
| 344 | func parseExprs(exprs []string) (tree.Exprs, error) { |
nothing calls this directly
no test coverage detected