gianm commented on a change in pull request #4551: Fixes and improvements to 
SQL metadata caching.
URL: https://github.com/apache/incubator-druid/pull/4551#discussion_r246458112
 
 

 ##########
 File path: sql/src/main/java/io/druid/sql/calcite/schema/DruidSchema.java
 ##########
 @@ -59,42 +58,66 @@
 import io.druid.sql.calcite.view.DruidViewMacro;
 import io.druid.sql.calcite.view.ViewManager;
 import io.druid.timeline.DataSegment;
-import org.apache.calcite.schema.Function;
 import org.apache.calcite.schema.Table;
 import org.apache.calcite.schema.impl.AbstractSchema;
 import org.joda.time.DateTime;
 
+import java.io.IOException;
+import java.util.Comparator;
 import java.util.EnumSet;
-import java.util.List;
+import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
 
 @ManageLifecycle
 public class DruidSchema extends AbstractSchema
 {
+  // Newest segments first, so they override older ones.
 
 Review comment:
   The idea is that Druid allows different segments to have different column 
types, and even allows the same column to have different types across different 
segments. But for SQL planning and metadata reporting purposes (e.g. 
INFORMATION_SCHEMA.COLUMNS) we can only report one type per column. We are 
preferring later segments (based on segment interval) over earlier ones if 
there's such a conflict, and achieve that by having `SEGMENT_ORDER` be an order 
that puts the newest segments first, and using it to affect the iteration order 
of `segmentMap.values()` in `buildDruidTable`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to