Search in sources :

Example 16 with NestableInput

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

the class SysShardsExpressionsTest method testPartitionIdentOfNonPartition.

@Test
public void testPartitionIdentOfNonPartition() throws Exception {
    // expression should return NULL on non partitioned tables
    Reference refInfo = refInfo("sys.shards.partition_ident", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertEquals("", 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 17 with NestableInput

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

the class SysShardsExpressionsTest method testSize.

@Test
public void testSize() throws Exception {
    Reference refInfo = refInfo("sys.shards.size", DataTypes.LONG, RowGranularity.SHARD);
    NestableInput<Long> shardExpression = (NestableInput<Long>) resolver.getImplementation(refInfo);
    assertEquals(Long.valueOf(123456), 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 18 with NestableInput

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

the class SysShardsExpressionsTest method testPartitionIdent.

@Test
public void testPartitionIdent() throws Exception {
    indexName = IndexParts.toIndexName("doc", "wikipedia_d1", "foo");
    prepare();
    Reference refInfo = refInfo("sys.shards.partition_ident", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertEquals("foo", shardExpression.value());
    // reset indexName
    indexName = "wikipedia_de";
}
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 19 with NestableInput

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

the class SysShardsExpressionsTest method test_retention_lease_is_null_on_index_shard_closed_exception.

@Test
public void test_retention_lease_is_null_on_index_shard_closed_exception() throws Exception {
    IndexShard mock = mockIndexShard();
    var shardId = mock.shardId();
    doThrow(new IndexShardClosedException(shardId)).when(mock).getRetentionLeaseStats();
    ShardReferenceResolver resolver = new ShardReferenceResolver(schemas, new ShardRowContext(mock, clusterService));
    Reference refInfo = refInfo("sys.shards.retention_leases", DataTypes.LONG, RowGranularity.SHARD, "version");
    NestableInput<Long> input = (NestableInput<Long>) resolver.getImplementation(refInfo);
    assertThat(input.value(), Matchers.nullValue());
}
Also used : ShardRowContext(io.crate.expression.reference.sys.shard.ShardRowContext) NestableInput(io.crate.expression.NestableInput) IndexShardClosedException(org.elasticsearch.index.shard.IndexShardClosedException) Reference(io.crate.metadata.Reference) IndexShard(org.elasticsearch.index.shard.IndexShard) ShardReferenceResolver(io.crate.metadata.shard.ShardReferenceResolver) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest) Test(org.junit.Test)

Example 20 with NestableInput

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

the class SysShardsExpressionsTest method testOrphanPartition.

@Test
public void testOrphanPartition() throws Exception {
    indexName = IndexParts.toIndexName("doc", "wikipedia_d1", "foo");
    prepare();
    Reference refInfo = refInfo("sys.shards.orphan_partition", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<Boolean> shardExpression = (NestableInput<Boolean>) resolver.getImplementation(refInfo);
    assertEquals(true, shardExpression.value());
    // reset indexName
    indexName = "wikipedia_de";
}
Also used : NestableInput(io.crate.expression.NestableInput) Reference(io.crate.metadata.Reference) 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