Search in sources :

Example 16 with Table

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()));
}
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 17 with Table

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();
}
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 18 with Table

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);
}
Also used : MatchingStats(com.bakdata.conquery.models.datasets.concepts.MatchingStats) Table(com.bakdata.conquery.models.datasets.Table) Test(org.junit.jupiter.api.Test)

Example 19 with Table

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);
}
Also used : Table(com.bakdata.conquery.models.datasets.Table) Import(com.bakdata.conquery.models.datasets.Import) 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) CentralRegistry(com.bakdata.conquery.models.identifiable.CentralRegistry) Test(org.junit.jupiter.api.Test) SneakyThrows(lombok.SneakyThrows)

Example 20 with Table

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();
    }
}
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)

Aggregations

Table (com.bakdata.conquery.models.datasets.Table)22 Column (com.bakdata.conquery.models.datasets.Column)12 Dataset (com.bakdata.conquery.models.datasets.Dataset)11 CentralRegistry (com.bakdata.conquery.models.identifiable.CentralRegistry)8 Test (org.junit.jupiter.api.Test)8 Validator (javax.validation.Validator)7 Import (com.bakdata.conquery.models.datasets.Import)6 TreeConcept (com.bakdata.conquery.models.datasets.concepts.tree.TreeConcept)6 CQTable (com.bakdata.conquery.apiv1.query.concept.filter.CQTable)5 ConceptTreeConnector (com.bakdata.conquery.models.datasets.concepts.tree.ConceptTreeConnector)5 Getter (lombok.Getter)5 Injectable (com.bakdata.conquery.io.jackson.Injectable)4 MutableInjectableValues (com.bakdata.conquery.io.jackson.MutableInjectableValues)4 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)4 Concept (com.bakdata.conquery.models.datasets.concepts.Concept)4 Connector (com.bakdata.conquery.models.datasets.concepts.Connector)4 Bucket (com.bakdata.conquery.models.events.Bucket)4 SneakyThrows (lombok.SneakyThrows)4 NamespaceStorage (com.bakdata.conquery.io.storage.NamespaceStorage)3 SecondaryIdDescription (com.bakdata.conquery.models.datasets.SecondaryIdDescription)3