github-advanced-security[bot] commented on code in PR #17065:
URL: https://github.com/apache/druid/pull/17065#discussion_r1759715118
##########
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java:
##########
@@ -442,20 +441,19 @@
+ "[metric3] seen in metricsSpec list (2 occurrences)"
);
- DataSchema schema = new DataSchema(
- IdUtilsTest.VALID_ID_CHARS,
- parser,
- new AggregatorFactory[]{
- new DoubleSumAggregatorFactory("metric1", "col1"),
- new DoubleSumAggregatorFactory("metric2", "col2"),
- new DoubleSumAggregatorFactory("metric1", "col3"),
- new DoubleSumAggregatorFactory("metric3", "col4"),
- new DoubleSumAggregatorFactory("metric3", "col5"),
- },
- new ArbitraryGranularitySpec(Granularities.DAY,
ImmutableList.of(Intervals.of("2014/2015"))),
- null,
- jsonMapper
- );
+ DataSchema schema = DataSchema.builder()
+ .withDataSource(IdUtilsTest.VALID_ID_CHARS)
+ .withParserMap(parser)
+ .withAggregators(
+ new
DoubleSumAggregatorFactory("metric1", "col1"),
+ new
DoubleSumAggregatorFactory("metric2", "col2"),
+ new
DoubleSumAggregatorFactory("metric1", "col3"),
+ new
DoubleSumAggregatorFactory("metric3", "col4"),
+ new
DoubleSumAggregatorFactory("metric3", "col5")
+ )
+ .withGranularity(ARBITRARY_GRANULARITY)
+ .withObjectMapper(jsonMapper)
+ .build();
Review Comment:
## Unread local variable
Variable 'DataSchema schema' is never read.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7821)
##########
server/src/main/java/org/apache/druid/segment/indexing/DataSchema.java:
##########
@@ -457,4 +413,108 @@
", inputRowParser=" + inputRowParser +
'}';
}
+
+ public static class Builder
+ {
+ private String dataSource;
+ private AggregatorFactory[] aggregators;
+ private GranularitySpec granularitySpec;
+ private TransformSpec transformSpec;
+ private Map<String, Object> parserMap;
+ private ObjectMapper objectMapper;
+
+ // The below fields can be initialized lazily from parser for backward
compatibility.
+ private TimestampSpec timestampSpec;
+ private DimensionsSpec dimensionsSpec;
+
+ public Builder()
+ {
+
+ }
+
+ public Builder(DataSchema schema)
+ {
+ this.dataSource = schema.getDataSource();
+ this.aggregators = schema.getAggregators();
+ this.granularitySpec = schema.getGranularitySpec();
+ this.transformSpec = schema.getTransformSpec();
+ this.parserMap = schema.getParserMap();
Review Comment:
## Deprecated method or constructor invocation
Invoking [DataSchema.getParserMap](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7824)
##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/ParallelIndexSupervisorTaskTest.java:
##########
@@ -325,25 +322,24 @@
expectedException.expect(IAE.class);
expectedException.expectMessage("Cannot use parser and inputSource
together. Try using inputFormat instead of parser.");
new ParallelIndexIngestionSpec(
- new DataSchema(
- "datasource",
- mapper.convertValue(
- new StringInputRowParser(
- new JSONParseSpec(
- new TimestampSpec(null, null, null),
- DimensionsSpec.EMPTY,
- null,
- null,
- null
- )
- ),
- Map.class
- ),
- null,
- null,
- null,
- mapper
- ),
+ DataSchema.builder()
+ .withDataSource("datasource")
+ .withParserMap(
+ mapper.convertValue(
+ new StringInputRowParser(
+ new JSONParseSpec(
+ new TimestampSpec(null, null, null),
+ DimensionsSpec.EMPTY,
+ null,
+ null,
+ null
+ )
+ ),
Review Comment:
## Deprecated method or constructor invocation
Invoking [StringInputRowParser.StringInputRowParser](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7822)
##########
indexing-service/src/test/java/org/apache/druid/indexing/seekablestream/SeekableStreamSamplerSpecTest.java:
##########
@@ -106,36 +105,37 @@
@Test(timeout = 10_000L)
public void testSampleWithInputRowParser() throws Exception
{
- final DataSchema dataSchema = new DataSchema(
- "test_ds",
- OBJECT_MAPPER.convertValue(
- new StringInputRowParser(
- new JSONParseSpec(
- new TimestampSpec("timestamp", "iso", null),
- new DimensionsSpec(
- Arrays.asList(
- new StringDimensionSchema("dim1"),
- new StringDimensionSchema("dim1t"),
- new StringDimensionSchema("dim2"),
- new LongDimensionSchema("dimLong"),
- new FloatDimensionSchema("dimFloat")
- )
- ),
- new JSONPathSpec(true, ImmutableList.of()),
- ImmutableMap.of(),
- false
- )
- ),
- Map.class
- ),
- new AggregatorFactory[]{
- new DoubleSumAggregatorFactory("met1sum", "met1"),
- new CountAggregatorFactory("rows")
- },
- new UniformGranularitySpec(Granularities.DAY, Granularities.NONE,
null),
- null,
- OBJECT_MAPPER
- );
+ DataSchema dataSchema = DataSchema.builder()
+ .withDataSource("test_ds")
+ .withParserMap(
+ OBJECT_MAPPER.convertValue(
+ new StringInputRowParser(
+ new JSONParseSpec(
+ new
TimestampSpec("timestamp", "iso", null),
+ new DimensionsSpec(
+ Arrays.asList(
+ new
StringDimensionSchema("dim1"),
+ new
StringDimensionSchema("dim1t"),
+ new
StringDimensionSchema("dim2"),
+ new
LongDimensionSchema("dimLong"),
+ new
FloatDimensionSchema("dimFloat")
+ )
+ ),
+ new JSONPathSpec(true,
ImmutableList.of()),
+ ImmutableMap.of(),
+ false
+ )
+ ),
Review Comment:
## Deprecated method or constructor invocation
Invoking [StringInputRowParser.StringInputRowParser](1) should be avoided
because it has been deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/7823)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]