use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TemplateConfigValidator method rebuildMetaDataStore.
// Rebuilds the MetaDataStore for each validation so that we can validate templates.
MetaDataStore rebuildMetaDataStore(Map<String, ConfigFile> resourceMap) {
DynamicConfigValidator validator = new DynamicConfigValidator(scanner, configRoot);
validator.validate(resourceMap);
MetaDataStore metaDataStore = new MetaDataStore(scanner, validator.getTables(), validator.getNamespaceConfigurations(), false);
// Populates the metadata store with SQL tables.
new SQLQueryEngine(metaDataStore, (unused) -> null, new HashSet<>(), new DefaultQueryPlanMerger(metaDataStore), new DefaultQueryValidator(metaDataStore.getMetadataDictionary()));
return metaDataStore;
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TableArgumentValidatorTest method testUndefinedTableArgsInTableSql.
@Test
public void testUndefinedTableArgsInTableSql() {
Table mainTable = mainTableBuilder.sql("SELECT something {{$$table.args.mainArg1}} blah {{$$table.args.mainArg2}} FROM").build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Argument 'mainArg2' is not defined but found '{{$$table.args.mainArg2}}' in table's sql.", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TableArgumentValidatorTest method testDefaultValueIsInValues.
@Test
public void testDefaultValueIsInValues() {
Table mainTable = mainTableBuilder.argument(Argument.builder().name("testArg").type(Type.INTEGER).values(Sets.newHashSet("1", "2")).defaultValue("5").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Default Value: '5' for Argument 'testArg' with Type 'INTEGER' must match one of these values: [1, 2].", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TableArgumentValidatorTest method testTableArgsTypeMismatchForJoinTable.
@Test
public void testTableArgsTypeMismatchForJoinTable() {
Table mainTable = mainTableBuilder.join(Join.builder().name("join").namespace("namespace").to("JoinTable").definition("start {{$$table.args.mainArg1}} end").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
tables.add(Table.builder().name("JoinTable").namespace("namespace").argument(Argument.builder().name("mainArg1").type(Type.TEXT).values(Collections.emptySet()).defaultValue("").build()).build());
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Argument type mismatch. Join table: 'namespace_JoinTable' has same Argument: 'mainArg1' with type 'TEXT'.", e.getMessage());
}
use of com.yahoo.elide.datastores.aggregation.queryengines.sql.SQLQueryEngine in project elide by yahoo.
the class TableArgumentValidatorTest method testUndefinedTableArgsInColumnDefinition.
@Test
public void testUndefinedTableArgsInColumnDefinition() {
Table mainTable = mainTableBuilder.dimension(Dimension.builder().name("dim1").type(Type.BOOLEAN).values(Collections.emptySet()).tags(Collections.emptySet()).definition("start {{$$table.args.mainArg1}} blah {{$$table.args.mainArg2}} end").build()).build();
Set<Table> tables = new HashSet<>();
tables.add(mainTable);
MetaDataStore metaDataStore = new MetaDataStore(DefaultClassScanner.getInstance(), tables, this.namespaceConfigs, true);
QueryPlanMerger merger = new DefaultQueryPlanMerger(metaDataStore);
Exception e = assertThrows(IllegalStateException.class, () -> new SQLQueryEngine(metaDataStore, connectionLookup, optimizers, merger, queryValidator));
assertEquals("Failed to verify table arguments for table: namespace_MainTable. Argument 'mainArg2' is not defined but found '{{$$table.args.mainArg2}}' in definition of column: 'dim1'.", e.getMessage());
}
Aggregations