Search in sources :

Example 51 with RelationName

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

the class FetchMarkerTest method test_fetch_marker_streams_as_if_it_is_a_fetchId_reference.

@Test
public void test_fetch_marker_streams_as_if_it_is_a_fetchId_reference() throws Exception {
    RelationName relationName = new RelationName("doc", "tbl");
    FetchMarker fetchMarker = new FetchMarker(relationName, List.of());
    BytesStreamOutput out = new BytesStreamOutput();
    Symbols.toStream(fetchMarker, out);
    StreamInput in = out.bytes().streamInput();
    Symbol symbol = Symbols.fromStream(in);
    assertThat(symbol, isReference(is(new ColumnIdent("_fetchid")), is(relationName), is(DataTypes.LONG)));
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) StreamInput(org.elasticsearch.common.io.stream.StreamInput) RelationName(io.crate.metadata.RelationName) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test)

Example 52 with RelationName

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

the class SymbolPrinterTest method testDocReference.

@Test
public void testDocReference() throws Exception {
    Reference r = new Reference(new ReferenceIdent(new RelationName("doc", "table"), new ColumnIdent("column", Arrays.asList("path", "nested"))), RowGranularity.DOC, DataTypes.STRING, 0, null);
    assertPrint(r, "doc.\"table\".\"column\"['path']['nested']");
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) DynamicReference(io.crate.expression.symbol.DynamicReference) FetchReference(io.crate.expression.symbol.FetchReference) Reference(io.crate.metadata.Reference) SymbolMatchers.isReference(io.crate.testing.SymbolMatchers.isReference) VoidReference(io.crate.expression.symbol.VoidReference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 53 with RelationName

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

the class SymbolPrinterTest method prepare.

@Before
public void prepare() throws Exception {
    String createTableStmt = "create table doc.formatter (" + "  foo text," + "  bar bigint," + "  \"CraZy\" ip," + "  \"1a\" int," + "  \"select\" char," + "  idx int," + "  s_arr array(text)" + ")";
    RelationName name = new RelationName(DocSchemaInfo.NAME, TABLE_NAME);
    DocTableInfo tableInfo = SQLExecutor.tableInfo(name, createTableStmt, clusterService);
    Map<RelationName, AnalyzedRelation> sources = Map.of(name, new TableRelation(tableInfo));
    sqlExpressions = new SqlExpressions(sources);
}
Also used : DocTableInfo(io.crate.metadata.doc.DocTableInfo) RelationName(io.crate.metadata.RelationName) AnalyzedRelation(io.crate.analyze.relations.AnalyzedRelation) SqlExpressions(io.crate.testing.SqlExpressions) TableRelation(io.crate.analyze.relations.TableRelation) Before(org.junit.Before)

Example 54 with RelationName

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

the class DocTableInfoBuilderTest method testNoTableInfoFromOrphanedPartition.

@Test
public void testNoTableInfoFromOrphanedPartition() throws Exception {
    String schemaName = randomSchema();
    PartitionName partitionName = new PartitionName(new RelationName(schemaName, "test"), Collections.singletonList("boo"));
    IndexMetadata.Builder indexMetadataBuilder = IndexMetadata.builder(partitionName.asIndexName()).settings(Settings.builder().put("index.version.created", Version.CURRENT).build()).numberOfReplicas(0).numberOfShards(5).putMapping(Constants.DEFAULT_MAPPING_TYPE, "{" + "  \"default\": {" + "    \"properties\":{" + "      \"id\": {" + "         \"type\": \"integer\"," + "         \"index\": \"not_analyzed\"" + "      }" + "    }" + "  }" + "}");
    Metadata metadata = Metadata.builder().put(indexMetadataBuilder).build();
    ClusterState state = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build();
    DocTableInfoBuilder builder = new DocTableInfoBuilder(nodeCtx, new RelationName(schemaName, "test"), state, new IndexNameExpressionResolver());
    expectedException.expect(RelationUnknown.class);
    expectedException.expectMessage(String.format(Locale.ENGLISH, "Relation '%s.test' unknown", schemaName));
    builder.build();
}
Also used : PartitionName(io.crate.metadata.PartitionName) ClusterState(org.elasticsearch.cluster.ClusterState) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) RelationName(io.crate.metadata.RelationName) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Test(org.junit.Test)

Example 55 with RelationName

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

the class MetadataIndexUpgraderTest method test_mappingMetadata_set_to_null.

@Test
public void test_mappingMetadata_set_to_null() throws Throwable {
    IndexMetadata indexMetadata = IndexMetadata.builder(new RelationName("blob", "b1").indexNameOrAlias()).settings(Settings.builder().put("index.version.created", Version.V_4_7_0)).numberOfShards(1).numberOfReplicas(0).putMapping(// here
    null).build();
    MetadataIndexUpgrader metadataIndexUpgrader = new MetadataIndexUpgrader();
    IndexMetadata updatedMetadata = metadataIndexUpgrader.apply(indexMetadata);
    assertThat(updatedMetadata.mapping(), is(nullValue()));
}
Also used : RelationName(io.crate.metadata.RelationName) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Test(org.junit.Test)

Aggregations

RelationName (io.crate.metadata.RelationName)180 Test (org.junit.Test)100 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)55 PartitionName (io.crate.metadata.PartitionName)47 Symbol (io.crate.expression.symbol.Symbol)42 Reference (io.crate.metadata.Reference)37 ColumnIdent (io.crate.metadata.ColumnIdent)31 AnalyzedRelation (io.crate.analyze.relations.AnalyzedRelation)21 ReferenceIdent (io.crate.metadata.ReferenceIdent)21 DocTableInfo (io.crate.metadata.doc.DocTableInfo)21 Map (java.util.Map)20 HashMap (java.util.HashMap)19 SqlExpressions (io.crate.testing.SqlExpressions)18 ArrayList (java.util.ArrayList)18 List (java.util.List)17 Before (org.junit.Before)17 DocTableRelation (io.crate.analyze.relations.DocTableRelation)13 SQLExecutor (io.crate.testing.SQLExecutor)11 CoordinatorTxnCtx (io.crate.metadata.CoordinatorTxnCtx)10 IndexTemplateMetadata (org.elasticsearch.cluster.metadata.IndexTemplateMetadata)10