Search in sources :

Example 21 with NestableInput

use of io.crate.expression.NestableInput in project crate by crate.

the class SysShardsExpressionsTest method testNumDocs.

@Test
public void testNumDocs() throws Exception {
    Reference refInfo = refInfo("sys.shards.num_docs", DataTypes.LONG, RowGranularity.SHARD);
    NestableInput<Long> shardExpression = (NestableInput<Long>) resolver.getImplementation(refInfo);
    assertEquals(Long.valueOf(654321), shardExpression.value());
    // second call should throw Exception
    assertNull(shardExpression.value());
}
Also used : NestableInput(io.crate.expression.NestableInput) Reference(io.crate.metadata.Reference) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 22 with NestableInput

use of io.crate.expression.NestableInput in project crate by crate.

the class SysShardsExpressionsTest method testSchemaName.

@Test
public void testSchemaName() throws Exception {
    Reference refInfo = refInfo("sys.shards.schema_name", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertEquals("doc", shardExpression.value());
}
Also used : NestableInput(io.crate.expression.NestableInput) Reference(io.crate.metadata.Reference) TestingHelpers.resolveCanonicalString(io.crate.testing.TestingHelpers.resolveCanonicalString) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 23 with NestableInput

use of io.crate.expression.NestableInput in project crate by crate.

the class SysShardsExpressionsTest method testState.

@Test
public void testState() throws Exception {
    Reference refInfo = refInfo("sys.shards.state", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertEquals("STARTED", shardExpression.value());
}
Also used : NestableInput(io.crate.expression.NestableInput) Reference(io.crate.metadata.Reference) TestingHelpers.resolveCanonicalString(io.crate.testing.TestingHelpers.resolveCanonicalString) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Aggregations

NestableInput (io.crate.expression.NestableInput)23 Reference (io.crate.metadata.Reference)22 Test (org.junit.Test)21 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)20 TestingHelpers.resolveCanonicalString (io.crate.testing.TestingHelpers.resolveCanonicalString)14 ShardRowContext (io.crate.expression.reference.sys.shard.ShardRowContext)2 ColumnIdent (io.crate.metadata.ColumnIdent)2 MapBackedRefResolver (io.crate.metadata.MapBackedRefResolver)2 RelationName (io.crate.metadata.RelationName)2 ShardReferenceResolver (io.crate.metadata.shard.ShardReferenceResolver)2 HashMap (java.util.HashMap)2 AlreadyClosedException (org.apache.lucene.store.AlreadyClosedException)2 IndexShard (org.elasticsearch.index.shard.IndexShard)2 ResourceUnknownException (io.crate.exceptions.ResourceUnknownException)1 UnhandledServerException (io.crate.exceptions.UnhandledServerException)1 PartitionName (io.crate.metadata.PartitionName)1 ReferenceIdent (io.crate.metadata.ReferenceIdent)1 DocTableInfo (io.crate.metadata.doc.DocTableInfo)1 Map (java.util.Map)1 IndexShardClosedException (org.elasticsearch.index.shard.IndexShardClosedException)1