clintropolis commented on code in PR #13732:
URL: https://github.com/apache/druid/pull/13732#discussion_r1095440950
##########
sql/src/main/java/org/apache/druid/sql/calcite/schema/SegmentMetadataCache.java:
##########
@@ -798,7 +798,20 @@ DatasourceTable.PhysicalDatasourceMetadata
buildDruidTable(final String dataSour
rowSignature.getColumnType(column)
.orElseThrow(() -> new ISE("Encountered null type
for column [%s]", column));
- columnTypes.putIfAbsent(column, columnType);
+ columnTypes.compute(column, (c, existingType) -> {
+ if (existingType == null) {
+ return columnType;
+ }
+ if (columnType == null) {
+ return existingType;
+ }
+ // if any are json, are all json
+ if (NestedDataComplexTypeSerde.TYPE.equals(columnType) ||
NestedDataComplexTypeSerde.TYPE.equals(existingType)) {
+ return NestedDataComplexTypeSerde.TYPE;
+ }
+ // "existing type" is the 'newest' type, since we iterate the
segments list by newest start time
+ return existingType;
+ });
Review Comment:
this is an area that could use improvement probably, but currently it will
do a 'refresh' that rebuilds the schema for a datasource from the available set
of segments, which calls this method, so its like ...iterating over all of them
to recompute the schema. See `segmentsNeedingRefresh` and
`dataSourcesNeedingRebuild` and such
--
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]