@Before public void setup() { // Create and Mock dependencies final SabotContext sabotContext = mock(SabotContext.class); final FunctionImplementationRegistry functionImplementationRegistry = mock(FunctionImplementationRegistry.class); final JavaTypeFactory typeFactory = JavaTypeFactoryImpl.INSTANCE; // Stub necessary methods when(sabotContext.getFunctionImplementationRegistry()).thenReturn(functionImplementationRegistry); // Utilize custom catalog reader implementation to return specific suggestions, // without requiring server startup MockCatalogReader mockCatalogReader = new MockCatalogReader(typeFactory, false); SqlValidatorWithHints validator = new SqlAdvisorValidator(new OperatorTable(sabotContext.getFunctionImplementationRegistry()), mockCatalogReader, typeFactory, DremioSqlConformance.INSTANCE); sqlAnalyzer = new SQLAnalyzer(validator); }
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; }
sabotContext.getClusterResourceInformation()); this.plannerSettings.setNumEndPoints(sabotContext.getExecutors().size()); this.table = new OperatorTable(sabotContext.getFunctionImplementationRegistry());
DremioCatalogReader catalogReader = new DremioCatalogReader(catalog, typeFactory); OperatorTable opTable = new OperatorTable(sabotContext.getFunctionImplementationRegistry()); SqlOperatorTable chainedOpTable = new ChainedSqlOperatorTable(ImmutableList.<SqlOperatorTable>of(opTable, catalogReader));