# CreateLiveViewStmt (ATTACH | CREATE) LIVE VIEW (IF NOT EXISTS)? tableIdentifier uuidClause? clusterClause? (WITH TIMEOUT DECIMAL_LITERAL?)? destinationClause? tableSchemaClause? subqueryClause
(pos Pos)
| 263 | // (ATTACH | CREATE) LIVE VIEW (IF NOT EXISTS)? tableIdentifier uuidClause? |
| 264 | // clusterClause? (WITH TIMEOUT DECIMAL_LITERAL?)? destinationClause? tableSchemaClause? subqueryClause |
| 265 | func (p *Parser) parseCreateLiveView(pos Pos) (*CreateLiveView, error) { |
| 266 | if err := p.expectKeyword(KeywordLive); err != nil { |
| 267 | return nil, err |
| 268 | } |
| 269 | |
| 270 | if err := p.expectKeyword(KeywordView); err != nil { |
| 271 | return nil, err |
| 272 | } |
| 273 | |
| 274 | createLiveView := &CreateLiveView{CreatePos: pos} |
| 275 | // parse IF NOT EXISTS clause if exists |
| 276 | var err error |
| 277 | createLiveView.IfNotExists, err = p.tryParseIfNotExists() |
| 278 | if err != nil { |
| 279 | return nil, err |
| 280 | } |
| 281 | |
| 282 | tableIdentifier, err := p.parseTableIdentifier(p.Pos()) |
| 283 | if err != nil { |
| 284 | return nil, err |
| 285 | } |
| 286 | createLiveView.Name = tableIdentifier |
| 287 | |
| 288 | // try parse UUID clause if exists |
| 289 | uuid, err := p.tryParseUUID() |
| 290 | if err != nil { |
| 291 | return nil, err |
| 292 | } |
| 293 | createLiveView.UUID = uuid |
| 294 | // parse ON CLUSTER clause if exists |
| 295 | onCluster, err := p.tryParseClusterClause(p.Pos()) |
| 296 | if err != nil { |
| 297 | return nil, err |
| 298 | } |
| 299 | createLiveView.OnCluster = onCluster |
| 300 | |
| 301 | withTimeout, err := p.tryParseWithTimeout(p.Pos()) |
| 302 | if err != nil { |
| 303 | return nil, err |
| 304 | } |
| 305 | createLiveView.WithTimeout = withTimeout |
| 306 | |
| 307 | if p.matchKeyword(KeywordTo) { |
| 308 | destination, err := p.parseDestinationClause(p.Pos()) |
| 309 | if err != nil { |
| 310 | return nil, err |
| 311 | } |
| 312 | createLiveView.Destination = destination |
| 313 | } |
| 314 | |
| 315 | if p.matchTokenKind(TokenKindLParen) { |
| 316 | tableSchema, err := p.parseTableSchemaClause(p.Pos()) |
| 317 | if err != nil { |
| 318 | return nil, err |
| 319 | } |
| 320 | createLiveView.TableSchema = tableSchema |
| 321 | } |
| 322 |
no test coverage detected