Search in sources :

Example 11 with TableIdent

use of io.crate.metadata.TableIdent in project crate by crate.

the class FetchBatchAccumulatorTest method buildFetchProjectorContext.

private FetchProjectorContext buildFetchProjectorContext() {
    Map<String, IntSet> nodeToReaderIds = new HashMap<>(2);
    IntSet nodeReadersNodeOne = new IntHashSet();
    nodeReadersNodeOne.add(0);
    IntSet nodeReadersNodeTwo = new IntHashSet();
    nodeReadersNodeTwo.add(2);
    nodeToReaderIds.put("nodeOne", nodeReadersNodeOne);
    nodeToReaderIds.put("nodeTwo", nodeReadersNodeTwo);
    TreeMap<Integer, String> readerIndices = new TreeMap<>();
    readerIndices.put(0, "t1");
    Map<String, TableIdent> indexToTable = new HashMap<>(1);
    indexToTable.put("t1", USER_TABLE_IDENT);
    Map<TableIdent, FetchSource> tableToFetchSource = new HashMap<>(2);
    FetchSource fetchSource = new FetchSource(Collections.emptyList(), Collections.singletonList(new InputColumn(0)), Collections.singletonList(ID));
    tableToFetchSource.put(USER_TABLE_IDENT, fetchSource);
    return new FetchProjectorContext(tableToFetchSource, nodeToReaderIds, readerIndices, indexToTable);
}
Also used : FetchSource(io.crate.planner.node.fetch.FetchSource) TableIdent(io.crate.metadata.TableIdent) InputColumn(io.crate.analyze.symbol.InputColumn)

Example 12 with TableIdent

use of io.crate.metadata.TableIdent in project crate by crate.

the class LuceneReferenceResolverTest method testGetImplementationWithColumnsOfTypeCollection.

@Test
public void testGetImplementationWithColumnsOfTypeCollection() {
    Reference arrayRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, DataTypes.DOUBLE_ARRAY);
    assertThat(luceneReferenceResolver.getImplementation(arrayRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
    Reference setRef = new Reference(new ReferenceIdent(new TableIdent("s", "t"), "a"), RowGranularity.DOC, new SetType(DataTypes.DOUBLE));
    assertThat(luceneReferenceResolver.getImplementation(setRef), instanceOf(DocCollectorExpression.ChildDocCollectorExpression.class));
}
Also used : SetType(io.crate.types.SetType) Reference(io.crate.metadata.Reference) TableIdent(io.crate.metadata.TableIdent) ReferenceIdent(io.crate.metadata.ReferenceIdent) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 13 with TableIdent

use of io.crate.metadata.TableIdent in project crate by crate.

the class SnapshotRestoreDDLDispatcherTest method testResolveTableIndexFromSnapshot.

@Test
public void testResolveTableIndexFromSnapshot() throws Exception {
    String resolvedIndex = SnapshotRestoreDDLDispatcher.ResolveFromSnapshotActionListener.resolveIndexNameFromSnapshot(new TableIdent("custom", "restoreme"), Collections.singletonList(new SnapshotInfo(new Snapshot("snapshot01", Collections.singletonList("custom.restoreme"), 0L))));
    assertThat(resolvedIndex, is("custom.restoreme"));
}
Also used : Snapshot(org.elasticsearch.snapshots.Snapshot) SnapshotInfo(org.elasticsearch.snapshots.SnapshotInfo) TableIdent(io.crate.metadata.TableIdent) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 14 with TableIdent

use of io.crate.metadata.TableIdent in project crate by crate.

the class SnapshotRestoreDDLDispatcherTest method testResolvePartitionedTableIndexFromSnapshot.

@Test
public void testResolvePartitionedTableIndexFromSnapshot() throws Exception {
    String resolvedIndex = SnapshotRestoreDDLDispatcher.ResolveFromSnapshotActionListener.resolveIndexNameFromSnapshot(new TableIdent(null, "restoreme"), Collections.singletonList(new SnapshotInfo(new Snapshot("snapshot01", Collections.singletonList(".partitioned.restoreme.046jcchm6krj4e1g60o30c0"), 0L))));
    String template = PartitionName.templateName(null, "restoreme") + "*";
    assertThat(resolvedIndex, is(template));
}
Also used : Snapshot(org.elasticsearch.snapshots.Snapshot) SnapshotInfo(org.elasticsearch.snapshots.SnapshotInfo) TableIdent(io.crate.metadata.TableIdent) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 15 with TableIdent

use of io.crate.metadata.TableIdent in project crate by crate.

the class WhereClauseAnalyzerTest method registerTables.

private void registerTables(SQLExecutor.Builder builder) {
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "users"), twoNodeRouting).add("id", DataTypes.STRING, null).add("name", DataTypes.STRING, null).add("tags", new ArrayType(DataTypes.STRING), null).addPrimaryKey("id").clusteredBy("id").build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "parted"), twoNodeRouting).add("id", DataTypes.INTEGER, null).add("name", DataTypes.STRING, null).add("date", DataTypes.TIMESTAMP, null, true).add("obj", DataTypes.OBJECT, null, ColumnPolicy.IGNORED).addPartitions(new PartitionName("parted", Arrays.asList(new BytesRef("1395874800000"))).asIndexName(), new PartitionName("parted", Arrays.asList(new BytesRef("1395961200000"))).asIndexName(), new PartitionName("parted", new ArrayList<BytesRef>() {

        {
            add(null);
        }
    }).asIndexName()).build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "parted_pk"), twoNodeRouting).addPrimaryKey("id").addPrimaryKey("date").add("id", DataTypes.INTEGER, null).add("name", DataTypes.STRING, null).add("date", DataTypes.TIMESTAMP, null, true).add("obj", DataTypes.OBJECT, null, ColumnPolicy.IGNORED).addPartitions(new PartitionName("parted_pk", Arrays.asList(new BytesRef("1395874800000"))).asIndexName(), new PartitionName("parted_pk", Arrays.asList(new BytesRef("1395961200000"))).asIndexName(), new PartitionName("parted_pk", new ArrayList<BytesRef>() {

        {
            add(null);
        }
    }).asIndexName()).build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "bystring"), twoNodeRouting).add("name", DataTypes.STRING, null).add("score", DataTypes.DOUBLE, null).addPrimaryKey("name").clusteredBy("name").build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "users_multi_pk"), twoNodeRouting).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).add("details", DataTypes.OBJECT, null).add("awesome", DataTypes.BOOLEAN, null).add("friends", new ArrayType(DataTypes.OBJECT), null, ColumnPolicy.DYNAMIC).addPrimaryKey("id").addPrimaryKey("name").clusteredBy("id").build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "pk4"), twoNodeRouting).add("i1", DataTypes.INTEGER, null).add("i2", DataTypes.INTEGER, null).add("i3", DataTypes.INTEGER, null).add("i4", DataTypes.INTEGER, null).addPrimaryKey("i1").addPrimaryKey("i2").addPrimaryKey("i3").addPrimaryKey("i4").build());
    builder.addDocTable(TestingTableInfo.builder(new TableIdent("doc", "users_clustered_by_only"), twoNodeRouting).add("id", DataTypes.LONG, null).add("name", DataTypes.STRING, null).add("details", DataTypes.OBJECT, null).add("awesome", DataTypes.BOOLEAN, null).add("friends", new ArrayType(DataTypes.OBJECT), null, ColumnPolicy.DYNAMIC).clusteredBy("id").build());
}
Also used : ArrayType(io.crate.types.ArrayType) PartitionName(io.crate.metadata.PartitionName) TableIdent(io.crate.metadata.TableIdent) BytesRef(org.apache.lucene.util.BytesRef)

Aggregations

TableIdent (io.crate.metadata.TableIdent)41 Test (org.junit.Test)18 CrateUnitTest (io.crate.test.integration.CrateUnitTest)15 PartitionName (io.crate.metadata.PartitionName)8 NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)7 Before (org.junit.Before)7 Reference (io.crate.metadata.Reference)6 DocTableInfo (io.crate.metadata.doc.DocTableInfo)6 List (java.util.List)5 Routing (io.crate.metadata.Routing)4 QualifiedName (io.crate.sql.tree.QualifiedName)4 BytesRef (org.apache.lucene.util.BytesRef)4 TableRelation (io.crate.analyze.relations.TableRelation)3 ReferenceIdent (io.crate.metadata.ReferenceIdent)3 TestingTableInfo (io.crate.metadata.table.TestingTableInfo)3 SqlExpressions (io.crate.testing.SqlExpressions)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 IntObjectHashMap (com.carrotsearch.hppc.IntObjectHashMap)2 ImmutableList (com.google.common.collect.ImmutableList)2 SharedShardContexts (io.crate.action.job.SharedShardContexts)2