List<RelMetadataProvider> list = Lists.newArrayList();
DefaultRelMetadataProvider defaultProvider =
new DefaultRelMetadataProvider();
list.add(defaultProvider);
planner.registerMetadataProviders(list);
RelMetadataProvider plannerChain = ChainedRelMetadataProvider.of(list);
relInitial.getCluster().setMetadataProvider(
new CachingRelMetadataProvider(plannerChain, planner));
planner.setRoot(relInitial);
RelNode relAfter = planner.findBestExp();