use of io.crate.metadata.RelationName in project crate by crate.
the class MetadataIndexUpgraderTest method test__all_is_removed_from_mapping.
@Test
public void test__all_is_removed_from_mapping() throws Throwable {
IndexMetadata indexMetadata = IndexMetadata.builder(new RelationName("doc", "users").indexNameOrAlias()).settings(Settings.builder().put("index.version.created", Version.V_3_2_0)).numberOfShards(1).numberOfReplicas(0).putMapping(Constants.DEFAULT_MAPPING_TYPE, "{" + " \"_all\": {\"enabled\": false}," + " \"properties\": {" + " \"name\": {" + " \"type\": \"keyword\"" + " }" + " }" + "}").build();
MetadataIndexUpgrader metadataIndexUpgrader = new MetadataIndexUpgrader();
IndexMetadata updatedMetadata = metadataIndexUpgrader.apply(indexMetadata);
MappingMetadata mapping = updatedMetadata.mapping();
assertThat(mapping.source().string(), Matchers.is("{\"default\":{\"properties\":{\"name\":{\"type\":\"keyword\"}}}}"));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class InsertPlannerTest method testInsertFromQueryWithPartitionedColumn.
@Test
public void testInsertFromQueryWithPartitionedColumn() {
Merge planNode = e.plan("insert into users (id, date) (select id, date from parted_pks)");
Collect queryAndFetch = (Collect) planNode.subPlan();
RoutedCollectPhase collectPhase = ((RoutedCollectPhase) queryAndFetch.collectPhase());
List<Symbol> toCollect = collectPhase.toCollect();
assertThat(toCollect.size(), is(2));
assertThat(toCollect.get(0), isReference("_doc['id']"));
assertThat(toCollect.get(1), equalTo(new Reference(new ReferenceIdent(new RelationName(Schemas.DOC_SCHEMA_NAME, "parted_pks"), "date"), RowGranularity.PARTITION, DataTypes.TIMESTAMPZ, ColumnPolicy.DYNAMIC, IndexType.PLAIN, true, true, 3, null)));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class WhereClauseAnalyzerTest method testSelectWherePartitionedByColumn.
@Test
public void testSelectWherePartitionedByColumn() throws Exception {
WhereClause whereClause = analyzeSelectWhere("select id from parted where date = 1395874800000");
assertThat(whereClause.queryOrFallback(), isLiteral(true));
assertThat(whereClause.partitions(), Matchers.contains(new PartitionName(new RelationName("doc", "parted"), Arrays.asList("1395874800000")).asIndexName()));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class WhereClauseAnalyzerTest method registerTables.
private void registerTables(SQLExecutor.Builder builder) throws IOException {
builder.addTable("create table users (" + " id string primary key," + " name string," + " tags array(string)" + ") clustered by (id)");
RelationName docParted = new RelationName("doc", "parted");
builder.addPartitionedTable("create table doc.parted (" + " id integer," + " name string," + " date timestamp with time zone," + " obj object (ignored)" + ") partitioned by (date)", new PartitionName(docParted, singletonList("1395874800000")).asIndexName(), new PartitionName(docParted, singletonList("1395961200000")).asIndexName(), new PartitionName(docParted, singletonList(null)).asIndexName());
builder.addTable("create table doc.users_multi_pk (" + " id long primary key," + " name string primary key," + " details object," + " awesome boolean," + " friends array(object)" + ") clustered by (id)");
builder.addTable("create table doc.pk4 (" + " i1 integer primary key," + " i2 integer primary key," + " i3 integer primary key," + " i4 integer primary key" + ")");
}
use of io.crate.metadata.RelationName in project crate by crate.
the class WhereClauseAnalyzerTest method prepare.
@Before
public void prepare() throws IOException {
SQLExecutor.Builder builder = SQLExecutor.builder(clusterService);
registerTables(builder);
RelationName docGeneratedCol = new RelationName("doc", "generated_col");
builder.addPartitionedTable("create table doc.generated_col (" + " ts timestamp with time zone ," + " x integer," + " y long," + " day as date_trunc('day', ts)," + " minus_y as y * -1," + " x_incr as x + 1" + ") partitioned by (day, minus_y)", new PartitionName(docGeneratedCol, Arrays.asList("1420070400000", "-1")).asIndexName(), new PartitionName(docGeneratedCol, Arrays.asList("1420156800000", "-2")).asIndexName());
RelationName docDoubleGenParted = new RelationName(DocSchemaInfo.NAME, "double_gen_parted");
builder.addPartitionedTable("create table doc.double_gen_parted (" + " x integer," + " x1 as x + 1," + " x2 as x + 2" + ") partitioned by (x1, x2)", new PartitionName(docDoubleGenParted, Arrays.asList("4", "5")).toString(), new PartitionName(docDoubleGenParted, Arrays.asList("5", "6")).toString());
e = builder.build();
}
Aggregations