(pos Pos)
| 1137 | } |
| 1138 | |
| 1139 | func (p *Parser) tryParseTTLPolicy(pos Pos) (*TTLPolicy, error) { |
| 1140 | var rule *TTLPolicyRule |
| 1141 | switch { |
| 1142 | case p.tryConsumeKeywords(KeywordTo): |
| 1143 | if p.tryConsumeKeywords(KeywordDisk) { |
| 1144 | value, err := p.parseString(p.Pos()) |
| 1145 | if err != nil { |
| 1146 | return nil, err |
| 1147 | } |
| 1148 | rule = &TTLPolicyRule{RulePos: pos, ToDisk: value} |
| 1149 | } else if p.tryConsumeKeywords(KeywordVolume) { |
| 1150 | value, err := p.parseString(p.Pos()) |
| 1151 | if err != nil { |
| 1152 | return nil, err |
| 1153 | } |
| 1154 | rule = &TTLPolicyRule{RulePos: pos, ToVolume: value} |
| 1155 | } else { |
| 1156 | return nil, fmt.Errorf("unexpected token: %q, expected DISK or VOLUME", p.lastTokenKind()) |
| 1157 | } |
| 1158 | case p.matchKeyword(KeywordDelete), p.matchKeyword(KeywordRecompress): |
| 1159 | token := p.last() |
| 1160 | _ = p.lexer.consumeToken() |
| 1161 | action := &TTLPolicyRuleAction{ |
| 1162 | ActionPos: token.Pos, |
| 1163 | ActionEnd: token.End, |
| 1164 | Action: token.ToString(), |
| 1165 | } |
| 1166 | codec, err := p.tryParseCompressionCodecs(p.Pos()) |
| 1167 | if err != nil { |
| 1168 | return nil, err |
| 1169 | } |
| 1170 | action.Codec = codec |
| 1171 | rule = &TTLPolicyRule{RulePos: pos, Action: action} |
| 1172 | default: |
| 1173 | return nil, nil // nolint |
| 1174 | } |
| 1175 | policy := &TTLPolicy{Item: rule} |
| 1176 | |
| 1177 | where, err := p.tryParseWhereClause(p.Pos()) |
| 1178 | if err != nil { |
| 1179 | return nil, err |
| 1180 | } |
| 1181 | policy.Where = where |
| 1182 | |
| 1183 | groupBy, err := p.tryParseGroupByClause(p.Pos()) |
| 1184 | if err != nil { |
| 1185 | return nil, err |
| 1186 | } |
| 1187 | policy.GroupBy = groupBy |
| 1188 | return policy, nil |
| 1189 | } |
| 1190 | |
| 1191 | func (p *Parser) parseTTLExpr(pos Pos) (*TTLExpr, error) { |
| 1192 | columnExpr, err := p.parseExpr(pos) |
no test coverage detected