use of io.crate.metadata.doc.DocTableInfo in project crate by crate.
the class DocTableRelationTest method testUpdatingCompoundPrimaryKeyThrowsCorrectException.
@Test
public void testUpdatingCompoundPrimaryKeyThrowsCorrectException() {
DocTableInfo tableInfo = SQLExecutor.tableInfo(new RelationName("doc", "t1"), "create table doc.t1 (i int, j int, primary key (i, j))", clusterService);
DocTableRelation rel = new DocTableRelation(tableInfo);
expectedException.expect(ColumnValidationException.class);
expectedException.expectMessage("Validation failed for i: Updating a primary key is not supported");
rel.ensureColumnCanBeUpdated(new ColumnIdent("i"));
}
use of io.crate.metadata.doc.DocTableInfo in project crate by crate.
the class SelectStatementAnalyzerTest method test_match_with_geo_shape_is_streamed_as_text_type_to_4_1_8_nodes.
@Test
public void test_match_with_geo_shape_is_streamed_as_text_type_to_4_1_8_nodes() throws Exception {
var executor = SQLExecutor.builder(clusterService).addTable("create table test (shape GEO_SHAPE)").build();
String stmt = "SELECT * FROM test WHERE MATCH (shape, 'POINT(1.2 1.3)')";
QueriedSelectRelation rel = executor.analyze(stmt);
Symbol where = rel.where();
assertThat(where, instanceOf(MatchPredicate.class));
DocTableInfo table = executor.resolveTableInfo("test");
EvaluatingNormalizer normalizer = new EvaluatingNormalizer(executor.nodeCtx, RowGranularity.DOC, null, new DocTableRelation(table));
Symbol normalized = normalizer.normalize(where, CoordinatorTxnCtx.systemTransactionContext());
assertThat(normalized, isFunction("match"));
Function match = (Function) normalized;
assertThat(match.arguments().get(1).valueType(), is(DataTypes.GEO_SHAPE));
assertThat(match.info().ident().argumentTypes().get(1), is(DataTypes.GEO_SHAPE));
BytesStreamOutput out = new BytesStreamOutput();
out.setVersion(Version.V_4_1_8);
match.writeTo(out);
StreamInput in = out.bytes().streamInput();
in.setVersion(Version.V_4_1_8);
Function serializedTo41 = new Function(in);
assertThat(serializedTo41.info().ident().argumentTypes().get(1), is(DataTypes.STRING));
}
use of io.crate.metadata.doc.DocTableInfo in project crate by crate.
the class PartitionPropertiesAnalyzerTest method testPartitionNameFromAssignmentWithBytesRef.
@Test
public void testPartitionNameFromAssignmentWithBytesRef() {
DocTableInfo tableInfo = SQLExecutor.partitionedTableInfo(new RelationName("doc", "users"), "create table doc.users (name text primary key) partitioned by (name)", clusterService);
PartitionName partitionName = getPartitionName(tableInfo);
assertThat(partitionName.values(), Matchers.contains("foo"));
assertThat(partitionName.asIndexName(), is(".partitioned.users.0426crrf"));
}
use of io.crate.metadata.doc.DocTableInfo in project crate by crate.
the class PartitionPropertiesAnalyzerTest method testPartitionNameOnRegularTable.
@Test
public void testPartitionNameOnRegularTable() {
DocTableInfo tableInfo = SQLExecutor.tableInfo(new RelationName("doc", "users"), "create table doc.users (name text primary key)", clusterService);
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("table 'doc.users' is not partitioned");
getPartitionName(tableInfo);
}
use of io.crate.metadata.doc.DocTableInfo in project crate by crate.
the class MetadataToASTNodeResolverTest method test_bit_string_length_is_shown_in_show_create_table_output.
@Test
public void test_bit_string_length_is_shown_in_show_create_table_output() throws Exception {
SQLExecutor e = SQLExecutor.builder(clusterService).addTable("create table tbl (xs bit(8))").build();
DocTableInfo table = e.resolveTableInfo("tbl");
CreateTable<?> node = MetadataToASTNodeResolver.resolveCreateTable(table);
assertThat(SqlFormatter.formatSql(node), Matchers.containsString("\"xs\" BIT(8)"));
}
Aggregations