@Before public void setUp() { optionManager = mock(OptionManager.class); when(optionManager.getOption("planner.timeout_per_phase_ms")).thenReturn(OptionValue.createLong(OptionType.QUERY, "planner.timeout_per_phase_ms", 100)); settings = new PlannerSettings(DremioTest.DEFAULT_SABOT_CONFIG, optionManager, null); }
@Before public void setup() { OptionManager optionManager = mock(OptionManager.class); ClusterResourceInformation info = mock(ClusterResourceInformation.class); when(info.getExecutorNodeCount()).thenReturn(1); PlannerSettings plannerSettings = new PlannerSettings(DremioTest.DEFAULT_SABOT_CONFIG, optionManager, info); cluster = RelOptCluster.create(new VolcanoPlanner(plannerSettings), rexBuilder); cluster.setMetadataProvider(DefaultRelMetadataProvider.INSTANCE); }
@Before public void setup() { optionManager = mock(OptionManager.class); when(optionManager.getOption(eq(ExecConstants.SLICE_TARGET))) .thenReturn(ExecConstants.SLICE_TARGET_OPTION.getDefault()); when(optionManager.getOption(eq(PlannerSettings.ENABLE_LEAF_LIMITS.getOptionName()))) .thenReturn(PlannerSettings.ENABLE_LEAF_LIMITS.getDefault()); when(optionManager.getOption(eq(PlannerSettings.ENABLE_TRIVIAL_SINGULAR.getOptionName()))) .thenReturn(PlannerSettings.ENABLE_TRIVIAL_SINGULAR.getDefault()); ClusterResourceInformation info = mock(ClusterResourceInformation.class); when(info.getExecutorNodeCount()).thenReturn(1); plannerSettings = new PlannerSettings(DremioTest.DEFAULT_SABOT_CONFIG, optionManager, info); cluster = RelOptCluster.create(new VolcanoPlanner(plannerSettings), rexBuilder); }
protected QueryContext mockQueryContext(SabotContext dbContext) throws Exception { final UserSession userSession = UserSession.Builder.newBuilder().withOptionManager(dbContext.getOptionManager()).build(); final SessionOptionManager sessionOptions = (SessionOptionManager) userSession.getOptions(); final QueryOptionManager queryOptions = new QueryOptionManager(sessionOptions); final ExecutionControls executionControls = new ExecutionControls(queryOptions, NodeEndpoint.getDefaultInstance()); final OperatorTable table = new OperatorTable(FUNCTIONS()); final LogicalPlanPersistence lp = dbContext.getLpPersistence(); final CatalogService registry = dbContext.getCatalogService(); final QueryContext context = Mockito.mock(QueryContext.class); when(context.getSession()).thenReturn(userSession); when(context.getLpPersistence()).thenReturn(lp); when(context.getCatalogService()).thenReturn(registry); when(context.getFunctionRegistry()).thenReturn(FUNCTIONS()); when(context.getSession()).thenReturn(UserSession.Builder.newBuilder().setSupportComplexTypes(true).build()); when(context.getCurrentEndpoint()).thenReturn(NodeEndpoint.getDefaultInstance()); when(context.getActiveEndpoints()).thenReturn(ImmutableList.of(NodeEndpoint.getDefaultInstance())); when(context.getPlannerSettings()).thenReturn(new PlannerSettings(dbContext.getConfig(), queryOptions, dbContext.getClusterResourceInformation())); when(context.getOptions()).thenReturn(queryOptions); when(context.getConfig()).thenReturn(DEFAULT_SABOT_CONFIG); when(context.getOperatorTable()).thenReturn(table); when(context.getAllocator()).thenReturn(allocator); when(context.getExecutionControls()).thenReturn(executionControls); when(context.getMaterializationProvider()).thenReturn(Mockito.mock(MaterializationDescriptorProvider.class)); return context; }
this.plannerSettings = new PlannerSettings(sabotContext.getConfig(), queryOptions, sabotContext.getClusterResourceInformation()); this.plannerSettings.setNumEndPoints(sabotContext.getExecutors().size());
@Override public GetServerMetaResp execute() throws Exception { final GetServerMetaResp.Builder respBuilder = GetServerMetaResp.newBuilder(); final ServerMeta.Builder metaBuilder = session.getRecordBatchFormat() != RecordBatchFormat.DRILL_1_0 ? ServerMeta.newBuilder(DEFAULT) : ServerMeta.newBuilder(DRILL_1_0_DEFAULT); PlannerSettings plannerSettings = new PlannerSettings(dContext.getConfig(), session.getOptions(), dContext.getClusterResourceInformation()); ParserConfig config = ParserConfig.newInstance(session, plannerSettings); int identifierMaxLength = config.identifierMaxLength(); Metadata metadata = SqlParser.create("", config).getMetadata(); metaBuilder .setMaxCatalogNameLength(identifierMaxLength) .setMaxColumnNameLength(identifierMaxLength) .setMaxCursorNameLength(identifierMaxLength) .setMaxSchemaNameLength(identifierMaxLength) .setMaxTableNameLength(identifierMaxLength) .setMaxUserNameLength(identifierMaxLength) .setIdentifierQuoteString(config.quoting().string) .setIdentifierCasing(getIdentifierCasing(config.unquotedCasing(), config.caseSensitive())) .setQuotedIdentifierCasing(getIdentifierCasing(config.quotedCasing(), config.caseSensitive())) .addAllSqlKeywords(Splitter.on(",").split(metadata.getJdbcKeywords())); respBuilder.setServerMeta(metaBuilder); respBuilder.setStatus(RequestStatus.OK); respBuilder.setQueryId(queryId); return respBuilder.build(); }