|
65 | 65 | import org.apache.druid.metadata.segment.SqlSegmentsMetadataManagerV2; |
66 | 66 | import org.apache.druid.metadata.segment.cache.HeapMemorySegmentMetadataCache; |
67 | 67 | import org.apache.druid.metadata.segment.cache.SegmentMetadataCache; |
| 68 | +import org.apache.druid.regex.RegexConfig; |
68 | 69 | import org.apache.druid.segment.DataSegmentsWithSchemas; |
69 | 70 | import org.apache.druid.segment.IndexIO; |
70 | 71 | import org.apache.druid.segment.IndexMergerV9Factory; |
@@ -361,6 +362,48 @@ public IndexMergerV9Factory getIndexMergerV9Factory() |
361 | 362 | return testUtils.getIndexMergerV9Factory(); |
362 | 363 | } |
363 | 364 |
|
| 365 | + /** |
| 366 | + * Converts ParseSpec to InputFormat for indexing tests. Used for backwards compatibility |
| 367 | + */ |
| 368 | + public static InputFormat createInputFormatFromParseSpec(ParseSpec parseSpec) |
| 369 | + { |
| 370 | + if (parseSpec instanceof JSONParseSpec) { |
| 371 | + JSONParseSpec jsonParseSpec = (JSONParseSpec) parseSpec; |
| 372 | + return new JsonInputFormat(jsonParseSpec.getFlattenSpec(), jsonParseSpec.getFeatureSpec(), jsonParseSpec.getKeepNullColumns(), null, null); |
| 373 | + } else if (parseSpec instanceof CSVParseSpec) { |
| 374 | + CSVParseSpec csvParseSpec = (CSVParseSpec) parseSpec; |
| 375 | + boolean getColumnsFromHeader = csvParseSpec.isHasHeaderRow() && csvParseSpec.getSkipHeaderRows() == 0; |
| 376 | + return new CsvInputFormat( |
| 377 | + csvParseSpec.getColumns(), |
| 378 | + csvParseSpec.getListDelimiter(), |
| 379 | + getColumnsFromHeader ? null : true, |
| 380 | + getColumnsFromHeader ? true : null, |
| 381 | + csvParseSpec.getSkipHeaderRows(), |
| 382 | + null |
| 383 | + ); |
| 384 | + } else if (parseSpec instanceof DelimitedParseSpec) { |
| 385 | + DelimitedParseSpec delimitedParseSpec = (DelimitedParseSpec) parseSpec; |
| 386 | + boolean getColumnsFromHeader = delimitedParseSpec.isHasHeaderRow() && delimitedParseSpec.getSkipHeaderRows() == 0; |
| 387 | + return new DelimitedInputFormat( |
| 388 | + delimitedParseSpec.getColumns(), |
| 389 | + delimitedParseSpec.getListDelimiter(), |
| 390 | + delimitedParseSpec.getDelimiter(), |
| 391 | + getColumnsFromHeader ? null : true, |
| 392 | + getColumnsFromHeader ? true : null, |
| 393 | + delimitedParseSpec.getSkipHeaderRows(), |
| 394 | + null |
| 395 | + ); |
| 396 | + } else if (parseSpec instanceof RegexParseSpec) { |
| 397 | + RegexParseSpec regexParseSpec = (RegexParseSpec) parseSpec; |
| 398 | + return new RegexInputFormat( |
| 399 | + regexParseSpec.getPattern(), |
| 400 | + regexParseSpec.getListDelimiter(), |
| 401 | + regexParseSpec.getColumns()); |
| 402 | + } else { |
| 403 | + throw new RE(StringUtils.format("Unsupported ParseSpec format %s", parseSpec.toString())); |
| 404 | + } |
| 405 | + } |
| 406 | + |
364 | 407 | public class TestLocalTaskActionClientFactory implements TaskActionClientFactory |
365 | 408 | { |
366 | 409 | @Override |
|
0 commit comments