Search in sources :

Example 11 with Column

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);
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Import(com.bakdata.conquery.models.datasets.Import) BitSetStore(com.bakdata.conquery.models.events.stores.primitive.BitSetStore) Dataset(com.bakdata.conquery.models.datasets.Dataset) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) BitSet(java.util.BitSet) ShortArrayStore(com.bakdata.conquery.models.events.stores.primitive.ShortArrayStore) DateRangeTypeCompound(com.bakdata.conquery.models.events.stores.specific.DateRangeTypeCompound) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) ColumnStore(com.bakdata.conquery.models.events.stores.root.ColumnStore) Column(com.bakdata.conquery.models.datasets.Column) Bucket(com.bakdata.conquery.models.events.Bucket) IntegerDateStore(com.bakdata.conquery.models.events.stores.primitive.IntegerDateStore) Validator(javax.validation.Validator) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 12 with Column

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()));
}
Also used : FETable(com.bakdata.conquery.apiv1.frontend.FETable) ValidityDate(com.bakdata.conquery.models.datasets.concepts.ValidityDate) FETable(com.bakdata.conquery.apiv1.frontend.FETable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) TreeConcept(com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept) ConceptTreeConnector(com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector) FEValue(com.bakdata.conquery.apiv1.frontend.FEValue) Test(org.junit.jupiter.api.Test)

Example 13 with Column

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();
}
Also used : Injectable(com.bakdata.conquery.io.jackson.Injectable) Table(com.bakdata.conquery.models.datasets.Table) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Column(com.bakdata.conquery.models.datasets.Column) Dataset(com.bakdata.conquery.models.datasets.Dataset) MutableInjectableValues(com.bakdata.conquery.io.jackson.MutableInjectableValues) ObjectReader(com.fasterxml.jackson.databind.ObjectReader) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Validator(javax.validation.Validator) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 14 with Column

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();
    }
}
Also used : CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) Table(com.bakdata.conquery.models.datasets.Table) Column(com.bakdata.conquery.models.datasets.Column) CQTable(com.bakdata.conquery.apiv1.query.concept.filter.CQTable) CQConcept(com.bakdata.conquery.apiv1.query.concept.specific.CQConcept) DateAggregationMode(com.bakdata.conquery.models.query.DateAggregationMode) QueryResolveContext(com.bakdata.conquery.models.query.QueryResolveContext)

Example 15 with Column

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);
}
Also used : Connector(com.bakdata.conquery.models.datasets.concepts.Connector) CQUnfilteredTable(com.bakdata.conquery.apiv1.query.concept.filter.CQUnfilteredTable) Column(com.bakdata.conquery.models.datasets.Column) TableExportQueryPlan(com.bakdata.conquery.models.query.queryplan.TableExportQueryPlan) TableExportDescription(com.bakdata.conquery.models.query.queryplan.TableExportQueryPlan.TableExportDescription) ArrayList(java.util.ArrayList)

Aggregations

Column (com.bakdata.conquery.models.datasets.Column)18 Table (com.bakdata.conquery.models.datasets.Table)10 Dataset (com.bakdata.conquery.models.datasets.Dataset)6 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)5 Validator (javax.validation.Validator)5 Injectable (com.bakdata.conquery.io.jackson.Injectable)4 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)4 SecondaryIdDescription (com.bakdata.conquery.models.datasets.SecondaryIdDescription)4 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)4 Test (org.junit.jupiter.api.Test)4 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)3 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)3 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)3 CQUnfilteredTable (com.bakdata.conquery.apiv1.query.concept.filter.CQUnfilteredTable)2 InternalOnly (com.bakdata.conquery.io.jackson.InternalOnly)2 CDateSet (com.bakdata.conquery.models.common.CDateSet)2 CDateRange (com.bakdata.conquery.models.common.daterange.CDateRange)2 Import (com.bakdata.conquery.models.datasets.Import)2 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)2 ValidityDate (com.bakdata.conquery.models.datasets.concepts.ValidityDate)2