use of com.bakdata.conquery.models.datasets.Column in project conquery by bakdata.
the class SerializationTests method bucketCompoundDateRange.
@Test
public void bucketCompoundDateRange() throws JSONException, IOException {
Dataset dataset = new Dataset();
dataset.setName("datasetName");
Table table = new Table();
Column startCol = new Column();
startCol.setName("startCol");
startCol.setType(MajorTypeId.DATE);
startCol.setTable(table);
Column endCol = new Column();
endCol.setLabel("endLabel");
endCol.setName("endCol");
endCol.setType(MajorTypeId.DATE);
endCol.setTable(table);
Column compoundCol = new Column();
compoundCol.setName("compoundCol");
compoundCol.setType(MajorTypeId.DATE_RANGE);
compoundCol.setTable(table);
table.setColumns(new Column[] { startCol, endCol, compoundCol });
table.setDataset(dataset);
table.setName("tableName");
Import imp = new Import(table);
imp.setName("importTest");
DateRangeTypeCompound compoundStore = new DateRangeTypeCompound(startCol.getName(), endCol.getName(), new BitSetStore(BitSet.valueOf(new byte[] { 0b1000 }), new BitSet(), 4));
// 0b1000 is a binary representation of 8 so that the 4th is set to make sure that BitSet length is 4.
ColumnStore startStore = new IntegerDateStore(new ShortArrayStore(new short[] { 1, 2, 3, 4 }, Short.MIN_VALUE));
ColumnStore endStore = new IntegerDateStore(new ShortArrayStore(new short[] { 5, 6, 7, 8 }, Short.MIN_VALUE));
Bucket bucket = new Bucket(0, 1, 4, new ColumnStore[] { startStore, endStore, compoundStore }, Collections.emptySet(), new int[0], new int[0], imp);
compoundStore.setParent(bucket);
CentralRegistry registry = new CentralRegistry();
registry.register(dataset);
registry.register(startCol);
registry.register(endCol);
registry.register(compoundCol);
registry.register(table);
registry.register(imp);
registry.register(bucket);
final Validator validator = Validators.newValidator();
SerializationTestUtil.forType(Bucket.class).registry(registry).injectables(new Injectable() {
@Override
public MutableInjectableValues inject(MutableInjectableValues values) {
return values.add(Validator.class, validator);
}
}).test(bucket);
}
use of com.bakdata.conquery.models.datasets.Column 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.Column 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.Column 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();
}
}
use of com.bakdata.conquery.models.datasets.Column in project conquery by bakdata.
the class TableExportQuery method createQueryPlan.
@Override
public TableExportQueryPlan createQueryPlan(QueryPlanContext context) {
List<TableExportDescription> resolvedConnectors = new ArrayList<>();
for (CQUnfilteredTable table : tables) {
Connector connector = table.getTable();
// if no dateColumn is provided, we use the default instead which is always the first one.
// Set to null if none-available in the connector.
final Column validityDateColumn = findValidityDateColumn(connector, table.getDateColumn());
final TableExportDescription exportDescription = new TableExportDescription(connector.getTable(), validityDateColumn);
resolvedConnectors.add(exportDescription);
}
return new TableExportQueryPlan(query.createQueryPlan(context), CDateRange.of(dateRange), resolvedConnectors, positions);
}
Aggregations