Search in sources :

Example 11 with NestableInput

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

the class EvaluatingNormalizerTest method prepare.

@Before
public void prepare() throws Exception {
    Map<ColumnIdent, NestableInput> referenceImplementationMap = new HashMap<>(1, 1);
    ReferenceIdent dummyLoadIdent = new ReferenceIdent(new RelationName("test", "dummy"), "load");
    dummyLoadInfo = new Reference(dummyLoadIdent, RowGranularity.NODE, DataTypes.DOUBLE, 0, null);
    referenceImplementationMap.put(dummyLoadIdent.columnIdent(), constant(0.08d));
    nodeCtx = createNodeContext();
    referenceResolver = new MapBackedRefResolver(referenceImplementationMap);
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) NestableInput(io.crate.expression.NestableInput) MapBackedRefResolver(io.crate.metadata.MapBackedRefResolver) HashMap(java.util.HashMap) Reference(io.crate.metadata.Reference) RelationName(io.crate.metadata.RelationName) ReferenceIdent(io.crate.metadata.ReferenceIdent) Before(org.junit.Before)

Example 12 with NestableInput

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

the class MapBackedRefResolverTest method testGetImplementation.

@Test
public void testGetImplementation() throws Exception {
    ReferenceResolver<NestableInput<?>> refResolver = new MapBackedRefResolver(Collections.singletonMap(new ColumnIdent("obj"), mock(NestableInput.class)));
    NestableInput implementation = refResolver.getImplementation(new Reference(new ReferenceIdent(USERS_TI, new ColumnIdent("obj", Arrays.asList("x", "z"))), RowGranularity.DOC, DataTypes.STRING, 0, null));
    assertThat(implementation, Matchers.nullValue());
}
Also used : NestableInput(io.crate.expression.NestableInput) Test(org.junit.Test)

Example 13 with NestableInput

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

the class SysShardsExpressionsTest method testId.

@Test
public void testId() throws Exception {
    Reference refInfo = refInfo("sys.shards.id", DataTypes.INTEGER, RowGranularity.SHARD);
    NestableInput<Integer> shardExpression = (NestableInput<Integer>) resolver.getImplementation(refInfo);
    assertEquals(Integer.valueOf(1), 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 14 with NestableInput

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

the class SysShardsExpressionsTest method testPathExpression.

@Test
public void testPathExpression() throws Exception {
    Reference refInfo = refInfo("sys.shards.path", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardPathExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertThat(shardPathExpression.value(), is(resolveCanonicalString("/dummy/" + indexUUID + "/1")));
}
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 15 with NestableInput

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

the class SysShardsExpressionsTest method testTableName.

@Test
public void testTableName() throws Exception {
    Reference refInfo = refInfo("sys.shards.table_name", DataTypes.STRING, RowGranularity.SHARD);
    NestableInput<String> shardExpression = (NestableInput<String>) resolver.getImplementation(refInfo);
    assertEquals("wikipedia_de", 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