use of com.bakdata.conquery.models.datasets.Table in project conquery by bakdata.
the class FEValueTest method sortedValidityDates.
@Test
public void sortedValidityDates() {
Dataset dataset = new Dataset();
dataset.setName("testDataset");
Table table = new Table();
table.setDataset(dataset);
table.setName("testTable");
Column column = new Column();
column.setName("testColumn");
column.setTable(table);
ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setName("testConnector");
TreeConcept concept = new TreeConcept();
concept.setDataset(dataset);
concept.setName("testConcept");
ValidityDate val0 = new ValidityDate();
val0.setName("val0");
val0.setConnector(connector);
ValidityDate val1 = new ValidityDate();
val1.setName("val1");
val1.setConnector(connector);
ValidityDate val2 = new ValidityDate();
val2.setName("val2");
val2.setConnector(connector);
List<ValidityDate> validityDates = List.of(val0, val1, val2);
connector.setColumn(column);
connector.setConcept(concept);
connector.setValidityDates(validityDates);
FETable feTable = FrontEndConceptBuilder.createTable(connector);
assertThat(feTable.getDateColumn().getOptions()).containsExactly(new FEValue("val0", val0.getId().toString()), new FEValue("val1", val1.getId().toString()), new FEValue("val2", val2.getId().toString()));
}
use of com.bakdata.conquery.models.datasets.Table in project conquery by bakdata.
the class GroovyIndexedTest method init.
@BeforeAll
public static void init() throws IOException, JSONException, ConfigurationException {
ObjectNode node = Jackson.MAPPER.readerFor(ObjectNode.class).readValue(In.resource(GroovyIndexedTest.class, CONCEPT_SOURCE).asStream());
// load concept tree from json
CentralRegistry registry = new CentralRegistry();
Table table = new Table();
table.setName("the_table");
Dataset dataset = new Dataset();
dataset.setName("the_dataset");
registry.register(dataset);
table.setDataset(dataset);
Column column = new Column();
column.setName("the_column");
column.setType(MajorTypeId.STRING);
table.setColumns(new Column[] { column });
column.setTable(table);
registry.register(table);
registry.register(column);
// Prepare Serdes injections
final Validator validator = Validators.newValidator();
final ObjectReader conceptReader = new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}.injectInto(registry.injectIntoNew(dataset.injectIntoNew(Jackson.MAPPER))).readerFor(Concept.class);
// load tree twice to to avoid references
indexedConcept = conceptReader.readValue(node);
indexedConcept.setDataset(dataset);
indexedConcept.initElements();
TreeChildPrefixIndex.putIndexInto(indexedConcept);
oldConcept = conceptReader.readValue(node);
oldConcept.setDataset(dataset);
oldConcept.initElements();
}
use of com.bakdata.conquery.models.datasets.Table in project conquery by bakdata.
the class MatchingStatsTests method addEventTest.
@Test
public void addEventTest() {
MatchingStats stats = new MatchingStats();
Table table = new Table();
table.setColumns(new Column[0]);
assertThat(stats.countEvents()).isEqualTo(0);
assertThat(stats.countEntities()).isEqualTo(0);
MatchingStats.Entry entry1 = new MatchingStats.Entry();
entry1.addEvent(table, null, 1, 1);
entry1.addEvent(table, null, 2, 1);
entry1.addEvent(table, null, 3, 2);
entry1.addEvent(table, null, 4, 2);
entry1.addEvent(table, null, 5, 3);
entry1.addEvent(table, null, 6, 3);
entry1.addEvent(table, null, 7, 4);
entry1.addEvent(table, null, 8, 4);
stats.putEntry(workerId1, entry1);
assertThat(stats.countEvents()).isEqualTo(8);
assertThat(stats.countEntities()).isEqualTo(4);
MatchingStats.Entry entry2 = new MatchingStats.Entry();
entry2.addEvent(table, null, 1, 1);
entry2.addEvent(table, null, 2, 2);
entry2.addEvent(table, null, 3, 3);
entry2.addEvent(table, null, 4, 4);
entry2.addEvent(table, null, 5, 5);
entry2.addEvent(table, null, 6, 6);
entry2.addEvent(table, null, 7, 7);
entry2.addEvent(table, null, 8, 8);
entry2.addEvent(table, null, 9, 9);
entry2.addEvent(table, null, 10, 10);
stats.putEntry(workerId2, entry2);
assertThat(stats.countEvents()).isEqualTo(18);
assertThat(stats.countEntities()).isEqualTo(14);
}
use of com.bakdata.conquery.models.datasets.Table in project conquery by bakdata.
the class CBlockTest method serialize.
@SneakyThrows
@Test
public void serialize() throws IOException, JSONException {
final CentralRegistry registry = new CentralRegistry();
final Dataset dataset = new Dataset();
dataset.setName("dataset");
final TreeConcept concept = new TreeConcept();
concept.setDataset(dataset);
concept.setName("concept");
final ConceptTreeConnector connector = new ConceptTreeConnector();
connector.setName("connector");
connector.setConcept(concept);
concept.setConnectors(List.of(connector));
final Table table = new Table();
table.setName("table");
table.setDataset(dataset);
final Import imp = new Import(table);
imp.setName("import");
final Bucket bucket = new Bucket(0, 0, 0, new ColumnStore[0], Collections.emptySet(), new int[10], new int[10], imp);
final CBlock cBlock = CBlock.createCBlock(connector, bucket, 10);
registry.register(dataset).register(table).register(concept).register(connector).register(bucket).register(imp);
SerializationTestUtil.forType(CBlock.class).registry(registry).test(cBlock);
}
use of com.bakdata.conquery.models.datasets.Table in project conquery by bakdata.
the class SecondaryIdQuery method resolve.
@Override
public void resolve(final QueryResolveContext context) {
DateAggregationMode resolvedDateAggregationMode = dateAggregationMode;
if (context.getDateAggregationMode() != null) {
log.trace("Overriding date aggregation mode ({}) with mode from context ({})", dateAggregationMode, context.getDateAggregationMode());
resolvedDateAggregationMode = context.getDateAggregationMode();
}
final QueryResolveContext resolvedContext = context.withDateAggregationMode(resolvedDateAggregationMode);
this.query = new ConceptQuery(root);
query.resolve(resolvedContext);
withSecondaryId = new HashSet<>();
withoutSecondaryId = new HashSet<>();
// TODO FK: can we refactor this into methods of CQConcept?
// partition tables by their holding of the requested SecondaryId.
// This assumes that from the root, only ConceptNodes hold TableIds we are interested in.
query.visit(queryElement -> {
if (!(queryElement instanceof CQConcept)) {
return;
}
final CQConcept concept = (CQConcept) queryElement;
for (CQTable connector : concept.getTables()) {
final Table table = connector.getConnector().getTable();
final Column secondaryIdColumn = findSecondaryIdColumn(table);
if (secondaryIdColumn != null && !concept.isExcludeFromSecondaryId()) {
withSecondaryId.add(secondaryIdColumn);
} else {
withoutSecondaryId.add(table);
}
}
});
// If there are no tables with the secondaryId, we fail as that is user error.
if (withSecondaryId.isEmpty()) {
throw new ConqueryError.NoSecondaryIdSelectedError();
}
}
Aggregations