github-advanced-security[bot] commented on code in PR #18223:
URL: https://github.com/apache/druid/pull/18223#discussion_r2196386347
##########
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java:
##########
@@ -582,30 +585,73 @@
DataSchema.class
);
- Assert.assertEquals(actual.getDataSource(), IdUtilsTest.VALID_ID_CHARS);
+ Assert.assertEquals(IdUtilsTest.VALID_ID_CHARS, actual.getDataSource());
Assert.assertEquals(
- actual.getParser().getParseSpec(),
new JSONParseSpec(
new TimestampSpec("xXx", null, null),
DimensionsSpec.builder().setDimensionExclusions(Arrays.asList("__time",
"metric1", "xXx", "col1")).build(),
null,
null,
null
- )
+ ),
+ actual.getParser().getParseSpec()
);
Assert.assertArrayEquals(
- actual.getAggregators(),
new AggregatorFactory[]{
new DoubleSumAggregatorFactory("metric1", "col1")
- }
+ },
+ actual.getAggregators()
);
Assert.assertEquals(
- actual.getGranularitySpec(),
new ArbitraryGranularitySpec(
new DurationGranularity(86400000, null),
ImmutableList.of(Intervals.of("2014/2015"))
- )
+ ),
+ actual.getGranularitySpec()
+ );
+ Assert.assertNull(actual.getProjections());
+ }
+
+ @Test
+ public void testSerdeWithProjections() throws Exception
+ {
+ // serialize, then deserialize of DataSchema with projections.
+ JSONParseSpec parseSpec = new JSONParseSpec(
+ new TimestampSpec("time", "auto", null),
+ new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of(
+ "dimB",
+ "dimA"
+ ))).withDimensionExclusions(ImmutableSet.of("__time", "time")),
+ null,
+ null,
+ null
+ );
+ AggregateProjectionSpec projectionSpec = new AggregateProjectionSpec(
+ "ab_count_projection",
+ null,
+ Arrays.asList(
+ new StringDimensionSchema("a"),
+ new LongDimensionSchema("b")
+ ),
+ new AggregatorFactory[]{
+ new CountAggregatorFactory("count")
+ }
);
+ DataSchema original = DataSchema.builder()
+ .withDataSource("datasource")
+ .withObjectMapper(jsonMapper)
+ .withParserMap(jsonMapper.convertValue(
+ new StringInputRowParser(parseSpec,
null),
+
JacksonUtils.TYPE_REFERENCE_MAP_STRING_OBJECT
+ ))
Review Comment:
## Deprecated method or constructor invocation
Invoking [Builder.withParserMap](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/9395)
##########
server/src/test/java/org/apache/druid/segment/indexing/DataSchemaTest.java:
##########
@@ -582,30 +585,73 @@
DataSchema.class
);
- Assert.assertEquals(actual.getDataSource(), IdUtilsTest.VALID_ID_CHARS);
+ Assert.assertEquals(IdUtilsTest.VALID_ID_CHARS, actual.getDataSource());
Assert.assertEquals(
- actual.getParser().getParseSpec(),
new JSONParseSpec(
new TimestampSpec("xXx", null, null),
DimensionsSpec.builder().setDimensionExclusions(Arrays.asList("__time",
"metric1", "xXx", "col1")).build(),
null,
null,
null
- )
+ ),
+ actual.getParser().getParseSpec()
);
Assert.assertArrayEquals(
- actual.getAggregators(),
new AggregatorFactory[]{
new DoubleSumAggregatorFactory("metric1", "col1")
- }
+ },
+ actual.getAggregators()
);
Assert.assertEquals(
- actual.getGranularitySpec(),
new ArbitraryGranularitySpec(
new DurationGranularity(86400000, null),
ImmutableList.of(Intervals.of("2014/2015"))
- )
+ ),
+ actual.getGranularitySpec()
+ );
+ Assert.assertNull(actual.getProjections());
+ }
+
+ @Test
+ public void testSerdeWithProjections() throws Exception
+ {
+ // serialize, then deserialize of DataSchema with projections.
+ JSONParseSpec parseSpec = new JSONParseSpec(
+ new TimestampSpec("time", "auto", null),
+ new DimensionsSpec(DimensionsSpec.getDefaultSchemas(ImmutableList.of(
+ "dimB",
+ "dimA"
+ ))).withDimensionExclusions(ImmutableSet.of("__time", "time")),
+ null,
+ null,
+ null
+ );
+ AggregateProjectionSpec projectionSpec = new AggregateProjectionSpec(
+ "ab_count_projection",
+ null,
+ Arrays.asList(
+ new StringDimensionSchema("a"),
+ new LongDimensionSchema("b")
+ ),
+ new AggregatorFactory[]{
+ new CountAggregatorFactory("count")
+ }
);
+ DataSchema original = DataSchema.builder()
+ .withDataSource("datasource")
+ .withObjectMapper(jsonMapper)
Review Comment:
## Deprecated method or constructor invocation
Invoking [Builder.withObjectMapper](1) should be avoided because it has been
deprecated.
[Show more
details](https://github.com/apache/druid/security/code-scanning/9396)
--
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]