|
26 | 26 | import org.apache.drill.common.PlanStringBuilder; |
27 | 27 | import org.apache.drill.common.exceptions.UserException; |
28 | 28 | import org.apache.drill.common.logical.FormatPluginConfig; |
29 | | -import org.apache.drill.exec.store.log.LogFormatField; |
30 | | -import org.apache.drill.exec.store.log.LogFormatPlugin; |
31 | 29 | import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList; |
32 | 30 | import org.slf4j.Logger; |
33 | 31 | import org.slf4j.LoggerFactory; |
@@ -151,6 +149,37 @@ public void validateFieldInput(){ |
151 | 149 | } |
152 | 150 | uniqueNames.add(name); |
153 | 151 | } |
| 152 | + List<Integer> fieldIndices = this.getFieldIndices(); |
| 153 | + List<Integer> fieldWidths = this.getFieldWidths(); |
| 154 | + int prevIndexAndWidth = -1; |
| 155 | + |
| 156 | + //assuming that fieldIndices is the same size as fieldWidths, width is required |
| 157 | + for (int i = 0; i<fieldIndices.size(); i++) { |
| 158 | + if (fieldIndices.get(i) < 0) { |
| 159 | + throw UserException |
| 160 | + .validationError() |
| 161 | + .message("Invalid index: " + fieldIndices.get(i) + ". Index must be >= 0.") |
| 162 | + .addContext("Plugin", FixedwidthFormatPlugin.DEFAULT_NAME) |
| 163 | + .build(logger); |
| 164 | + } |
| 165 | + /* |
| 166 | + else if (fieldWidths.get(i) == null || fieldWidths.get(i) < 1) { |
| 167 | + if (i == fieldIndices.size()-1) { |
| 168 | + Integer width = |
| 169 | + } |
| 170 | + Integer width = fieldIndices.get(i+1) - fieldIndices.get(i); |
| 171 | + fieldWidths.set(i, width); |
| 172 | + } |
| 173 | + */ |
| 174 | + else if (fieldIndices.get(i) <= prevIndexAndWidth) { |
| 175 | + throw UserException |
| 176 | + .validationError() |
| 177 | + .message("Overlapping fields at indices " + fieldIndices.get(i-1) + "and" + fieldIndices.get(i) + ".") |
| 178 | + .addContext("Plugin", FixedwidthFormatPlugin.DEFAULT_NAME) |
| 179 | + .build(logger); |
| 180 | + } |
| 181 | + prevIndexAndWidth = fieldIndices.get(i) + fieldWidths.get(i); |
| 182 | + } |
154 | 183 | } |
155 | 184 |
|
156 | 185 |
|
|
0 commit comments