use of io.crate.metadata.RelationName in project crate by crate.
the class CopyAnalyzerTest method testCopyToWithPartitionIdentAndPartitionInWhereClause.
@Test
public void testCopyToWithPartitionIdentAndPartitionInWhereClause() throws Exception {
BoundCopyTo analysis = analyze("COPY parted PARTITION (date=1395874800000) WHERE date = 1395874800000 TO DIRECTORY '/tmp/foo'");
String parted = new PartitionName(new RelationName("doc", "parted"), Collections.singletonList("1395874800000")).asIndexName();
assertThat(analysis.whereClause().partitions(), contains(parted));
}
use of io.crate.metadata.RelationName in project crate by crate.
the class CreateViewAnalyzerTest method testCreateViewCreatesViewInDefaultSchema.
@Test
public void testCreateViewCreatesViewInDefaultSchema() {
SQLExecutor sqlExecutor = SQLExecutor.builder(clusterService).setSearchPath("firstSchema", "secondSchema").build();
CreateViewStmt createView = sqlExecutor.analyze("create view v1 as select * from sys.nodes");
assertThat(createView.name(), is(new RelationName(sqlExecutor.getSessionContext().searchPath().currentSchema(), "v1")));
}
use of io.crate.metadata.RelationName 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.RelationName 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.RelationName in project crate by crate.
the class CommonQueryBuilderTest method testWhereRefEqNullWithDifferentTypes.
@Test
public void testWhereRefEqNullWithDifferentTypes() throws Exception {
for (DataType<?> type : DataTypes.PRIMITIVE_TYPES) {
if (type.storageSupport() == null) {
continue;
}
// ensure the test is operating on a fresh, empty cluster state (no existing tables)
resetClusterService();
DocTableInfo tableInfo = SQLExecutor.tableInfo(new RelationName(DocSchemaInfo.NAME, "test_primitive"), "create table doc.test_primitive (" + " x " + type.getName() + ")", clusterService);
TableRelation tableRelation = new TableRelation(tableInfo);
Map<RelationName, AnalyzedRelation> tableSources = Map.of(tableInfo.ident(), tableRelation);
SqlExpressions sqlExpressions = new SqlExpressions(tableSources, tableRelation, User.CRATE_USER);
Query query = convert(sqlExpressions.normalize(sqlExpressions.asSymbol("x = null")));
// must always become a MatchNoDocsQuery
// string: term query with null would cause NPE
// int/numeric: rangeQuery from null to null would match all
// bool: term would match false too because of the condition in the eq query builder
assertThat(query, instanceOf(MatchNoDocsQuery.class));
}
}
Aggregations