use of io.crate.metadata.table.TableInfo in project crate by crate.
the class CopyAnalyzerTest method testCopyToFileWithPartitionedTable.
@Test
public void testCopyToFileWithPartitionedTable() throws Exception {
CopyToAnalyzedStatement analysis = e.analyze("copy parted to directory '/blah'");
TableInfo tableInfo = analysis.subQueryRelation().tableRelation().tableInfo();
assertThat(tableInfo.ident(), is(TEST_PARTITIONED_TABLE_IDENT));
assertThat(analysis.overwrites().size(), is(1));
}
use of io.crate.metadata.table.TableInfo in project crate by crate.
the class CopyAnalyzerTest method testCopyToFileWithCompressionParams.
@Test
public void testCopyToFileWithCompressionParams() throws Exception {
CopyToAnalyzedStatement analysis = e.analyze("copy users to directory '/blah' with (compression='gzip')");
TableInfo tableInfo = analysis.subQueryRelation().tableRelation().tableInfo();
assertThat(tableInfo.ident(), is(USER_TABLE_IDENT));
assertThat(analysis.uri(), isLiteral("/blah"));
assertThat(analysis.compressionType(), is(WriterProjection.CompressionType.GZIP));
}
use of io.crate.metadata.table.TableInfo in project crate by crate.
the class InternalCountOperationTest method testCount.
@Test
public void testCount() throws Exception {
execute("create table t (name string) clustered into 1 shards with (number_of_replicas = 0)");
ensureYellow();
execute("insert into t (name) values ('Marvin'), ('Arthur'), ('Trillian')");
execute("refresh table t");
CountOperation countOperation = internalCluster().getDataNodeInstance(CountOperation.class);
assertThat(countOperation.count("t", 0, WhereClause.MATCH_ALL), is(3L));
Schemas schemas = internalCluster().getInstance(Schemas.class);
TableInfo tableInfo = schemas.getTableInfo(new TableIdent(null, "t"));
TableRelation tableRelation = new TableRelation(tableInfo);
Map<QualifiedName, AnalyzedRelation> tableSources = ImmutableMap.<QualifiedName, AnalyzedRelation>of(new QualifiedName(tableInfo.ident().name()), tableRelation);
SqlExpressions sqlExpressions = new SqlExpressions(tableSources, tableRelation);
WhereClause whereClause = new WhereClause(sqlExpressions.normalize(sqlExpressions.asSymbol("name = 'Marvin'")));
assertThat(countOperation.count("t", 0, whereClause), is(1L));
}
use of io.crate.metadata.table.TableInfo in project crate by crate.
the class HandlerSideLevelCollectTest method testClusterLevel.
@Test
public void testClusterLevel() throws Exception {
Schemas schemas = internalCluster().getInstance(Schemas.class);
TableInfo tableInfo = schemas.getTableInfo(new TableIdent("sys", "cluster"));
Routing routing = tableInfo.getRouting(WhereClause.MATCH_ALL, null);
Reference clusterNameRef = new Reference(new ReferenceIdent(SysClusterTableInfo.IDENT, new ColumnIdent(ClusterNameExpression.NAME)), RowGranularity.CLUSTER, DataTypes.STRING);
RoutedCollectPhase collectNode = collectNode(routing, Arrays.<Symbol>asList(clusterNameRef), RowGranularity.CLUSTER);
Bucket result = collect(collectNode);
assertThat(result.size(), is(1));
assertThat(((BytesRef) result.iterator().next().get(0)).utf8ToString(), Matchers.startsWith("SUITE-"));
}
use of io.crate.metadata.table.TableInfo in project crate by crate.
the class HandlerSideLevelCollectTest method testInformationSchemaTables.
@Test
public void testInformationSchemaTables() throws Exception {
InformationSchemaInfo schemaInfo = internalCluster().getInstance(InformationSchemaInfo.class);
TableInfo tablesTableInfo = schemaInfo.getTableInfo("tables");
Routing routing = tablesTableInfo.getRouting(WhereClause.MATCH_ALL, null);
List<Symbol> toCollect = new ArrayList<>();
for (Reference reference : tablesTableInfo.columns()) {
toCollect.add(reference);
}
Symbol tableNameRef = toCollect.get(8);
FunctionImplementation eqImpl = functions.get(new FunctionIdent(EqOperator.NAME, ImmutableList.of(DataTypes.STRING, DataTypes.STRING)));
Function whereClause = new Function(eqImpl.info(), Arrays.asList(tableNameRef, Literal.of("shards")));
RoutedCollectPhase collectNode = collectNode(routing, toCollect, RowGranularity.DOC, new WhereClause(whereClause));
Bucket result = collect(collectNode);
assertThat(TestingHelpers.printedTable(result), is("NULL| NULL| strict| 0| 1| NULL| NULL| NULL| shards| sys| NULL\n"));
}
Aggregations